Part Number Hot Search : 
MB89P X1TCG F103J 56WVRA EL5178IS AC1506 A1104 CUPPB
Product Description
Full Text Search
 

To Download AT89C5131A-TISIL Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  rev. 4338e?usb?06/06 features ? 80c52x2 core (6 clocks per instruction) ? maximum core frequency 48 mhz in x1 mode, 24 mhz in x2 mode ? dual data pointer ? full-duplex enhanced uart (euart) ? three 16-bit timer/counters: t0, t1 and t2 ? 256 bytes of scratchpad ram ? 16/32-kbyte on-chip flash eeprom in-system programming through usb ? byte and page (128 bytes) erase and write ? 100k write cycles ? 3-kbyteflash eeprom for bootloader ? byte and page (128 bytes) erase and write ? 100k write cycles ? 1-kbyte eeprom data ( ? byte and page (128 bytes) erase and write ? 100k write cycles ? on-chip expanded ram (eram): 1024 bytes ? integrated power monitor (por/pfd) to supervise internal power supply ? usb 1.1 and 2.0 full speed compliant module with interrupt on transfer completion ? endpoint 0 for control transfers: 32-byte fifo ? 6 programmable endpoints with in or out directions and with bulk, interrupt or isochronous transfers ? endpoint 1, 2, 3: 32-byte fifo ? endpoint 4, 5: 2 x 64-byte fifo with double buffering (ping-pong mode) ? endpoint 6: 2 x 512-byte fifo with double buffering (ping-pong mode) ? suspend/resume interrupts ? power-on reset and usb bus reset ? 48 mhz dpll for full-speed bus operation ? usb bus disconnection on microcontroller request ? 5 channels programmable counter array (pca) with 16-bit counter, high-speed output, compare/capture, pwm and watchdog timer capabilities ? programmable hardware watchdog timer (one-time enabled with reset-out): 50 ms to 6s at 4 mhz ? keyboard interrupt interface on port p1 (8 bits) ? twi (two wire interface) 400kbit/s ? spi interface (master/slave mode) ? 34 i/o pins ? 4 direct-drive led outputs with programmable current sources: 2-6-10 ma typical ? 4-level priority interrupt system (11 sources) ? idle and power-down modes ? 0 to 32 mhz on-chip oscillator with analog pll for 48 mhz synthesis ? industrial temperature range ? low voltage range supply: 2.7v to 3.6v (3.0v to 3.6v required for usb) ? packages: so28, plcc52, vqfp64 8-bit flash microcontroller with full speed usb device at89c5131a-l
2 at89c5131a-l 4338e?usb?06/06 description at89c5131a-l is a high-performance flash version of the 80c51 single-chip 8-bit microcontrollers with full speed usb functions. at89c5131a-l features a full-speed usb module compatible with the usb specifica- tions version 1.1 and 2.0. this module integrates the usb transceivers with a 3.3v voltage regulator and the serial interface engine (sie) with digital phase locked loop and 48 mhz clock recovery. usb event detection logic (reset and suspend/resume) and fifo buffers supporting the mandatory control endpoint (ep0) and up to 6 versatile endpoints (ep1/ep2/ep3/ep4/ep5/ep6) with minimum software overhead are also part of the usb module. at89c5131a-l retains the features of the atmel 80c52 with extended flash capacity (32-kbyte), 256 bytes of internal ram, a 4-level interrupt system, two 16-bit timer/counters (t0/t1), a full duplex enhanced uart (euart) and an on-chip oscillator. in addition, at89c5131a-l has an on-chip expanded ram of 1024 bytes (eram), a dual- data pointer, a 16-bit up/down timer (t2), a programmable counter array (pca), up to 4 programmable led current sources, a programmable hardware watchdog and a power-on reset. at89c5131a-l has two software-selectable modes of reduced activity for further reduc- tion in power consumption. in the idle mode the cpu is frozen while the timers, the serial ports and the interrupt system are still operating. in the power-down mode the ram is saved, the peripheral clock is frozen, but the device has full wake-up capability through usb events or external interrupts.
3 at89c5131a-l 4338e?usb?06/06 block diagram notes: 1. alternate function of port 1 2. alternate function of port 3 3. alternate function of port 4 timer 0 int ram 256x8 t0 t1 rxd txd wr rd ea psen ale xtal2 xtal1 euart cpu timer 1 int1 ctrl int0 (2) (2) c51 core (2) (2) (2) (2) port 0 p0 port 1 port 2 port 3 parallel i/o ports & ext. bus p1 p2 p3 eram 1kx8 pca rst watch dog cex eci vss vdd (2) (2) (1) (1) timer2 t2ex t2 (1) (1) port 4 p4 32kx8 flash + brg usb d - d + vref regu- key board kin lator avss eeprom 4kx8 spi miso mosi sck (1) (1) (1) ss (1) avdd twi scl sda
4 at89c5131a-l 4338e?usb?06/06 pinout description pinout figure 1. at89c5131a-l 52-pin plcc pinout 21 22 26 25 24 23 29 28 27 30 31 5 4 3 2 1 6 52 51 50 49 48 8 9 10 11 12 13 14 15 16 17 18 46 45 44 43 42 41 40 39 38 37 36 plcc52 7 47 19 20 32 33 34 35 p1.1/t2ex/kin1/ss p1.0/t2/kin0 p0.6/ad6 ale p0.7/ad7 ea psen p1.7/cex4/kin7/mos i p1.3/cex0/kin3 p1.5/cex2/kin5/miso p1.6/cex3/kin6/sck pllf p3.0/rxd avss p2.6/a14 xtal1 p2.5/a13 p0.3/ad3 p0.5/ad5 p0.4/ad4 vref p0.2/ad2 p0.0/ad0 p0.1/ad1 avd d nc p3.2/int0 p3.6/wr /led2 xtal2 rst p3.1/txd p3.3/int1 /led0 p3.7/rd /led3 d- p2.0/a8 p2.1/a9 p2.2/a10 p2.3/a11 vss p2.4/a12 p4.1/sda d+ p4.0/scl p1.2/eci/kin2 p1.4/cex1/kin4 p3.4/t0 p3.5/t1/led1 nc nc vdd nc p2.7/a15
5 at89c5131a-l 4338e?usb?06/06 figure 2. at89c5131a-l 64-pin vqfp pinout figure 3. at89c5131a-l 28-pin so pinout 17 18 22 21 20 19 25 24 23 26 27 62 61 60 59 58 63 57 56 55 54 53 1 2 3 4 5 6 7 8 9 10 11 48 47 46 45 44 43 42 41 40 39 38 vqfp64 64 52 12 13 28 29 36 37 51 50 49 35 33 34 14 15 16 30 31 32 p1.1/t2ex/kin1/ss ale ea psen p1.7/cex4/kin7/mos i p1.3/cex0/kin3 p1.5/cex2/kin5/miso p1.6/cex3/kin6/sck p2.7/a15 p2.6/a14 p4.1/sda p1.2/eci/kin2 p1.4/cex1/kin4 p1.0/t2/kin0 pllf nc xtal2 rst p3.7/rd /led3 p2.0/a8 p2.1/a9 p2.2/a10 p2.3/a11 p2.4/a12 nc nc p3.0/rxd nc vref p0.0/ad0 avs s p3.2/int0 p3.6/wr /led2 p3.1/txd p3.3/int1 /led0 vss p3.4/t0 p3.5/t1/led1 nc p0.6/ad6 p0.7/ad7 p2.5/a13 p0.3/ad3 p0.5/ad5 p0.4/ad4 p0.2/ad2 p0.1/ad1 d- d+ p4.0/scl xtal1 av dd nc nc nc nc nc nc nc nc nc nc nc vdd p1.1/t2ex/kin1/ss pllf p3.0/rxd p1.0/t2/kin0 avss vdd xtal1 xtal2 p3.2/int0 p3.5/t1/led1 p3.6/wr/led2 p3.7/rd/led3 d- p1.4/cex1/kin4 vss d+ p1.2/eci/kin2 p1.3/cex0/kin3 p1.5/cex2/kin5/miso rst p1.6/cex3/kin6/sck p1.7/cex4/kin7/mosi p4.0/scl vref p3.1/txd p3.4/t0 1 2 3 4 5 6 7 8 9 10 11 12 28 27 26 25 24 23 22 21 20 19 18 17 so28 13 14 16 15 p4.1/sda p3.3/int1/led0
6 at89c5131a-l 4338e?usb?06/06 signals all the at89c5131a-l signals are detailed by functionality on table 1 through table 12. table 1. keypad interface signal description table 2. programmable counter array signal description table 3. serial i/o signal description signal name type description alternate function kin[7:0) i keypad input lines holding one of these pins high or low for 24 oscillator periods triggers a keypad interrupt if enabled. held line is reported in the kbcon register. p1[7:0] signal name type description alternate function eci i external clock input p1.2 cex[4:0] i/o capture external input compare external output p1.3 p1.4 p1.5 p1.6 p1.7 signal name type description alternate function rxd i serial input the serial input for extended uart. p3.0 txd o serial output the serial output for extended uart. p3.1 table 4. timer 0, timer 1 and timer 2 signal description signal name type description alternate function int0 i timer 0 gate input int0 serves as external run control for timer 0, when selected by gate0 bit in tcon register. external interrupt 0 int0 input set ie0 in the tcon register. if bit it0 in this register is set, bits ie0 are set by a falling edge on int0 . if bit it0 is cleared, bits ie0 is set by a low level on int0 . p3.2 int1 i timer 1 gate input int1 serves as external run control for timer 1, when selected by gate1 bit in tcon register. external interrupt 1 int1 input set ie1 in the tcon register. if bit it1 in this register is set, bits ie1 are set by a falling edge on int1 . if bit it1 is cleared, bits ie1 is set by a low level on int1 . p3.3
7 at89c5131a-l 4338e?usb?06/06 table 5. led signal description table 6. twi signal description table 7. spi signal description t0 i timer counter 0 external clock input when timer 0 operates as a counter, a falling edge on the t0 pin increments the count. p3.4 t1 i timer/counter 1 external clock input when timer 1 operates as a counter, a falling edge on the t1 pin increments the count. p3.5 t2 i o timer/counter 2 external clock input timer/counter 2 clock output p1.0 t2ex i timer/counter 2 reload/capture/direction control input p1.1 signal name type description alternate function led[3:0] o direct drive led output these pins can be directly connected to the cathode of standard leds without external current limiting resistors. the typical current of each output can be programmed by software to 2, 6 or 10 ma. several outputs can be connected together to get higher drive capabilities. p3.3 p3.5 p3.6 p3.7 signal name type description alternate function scl i/o scl: twi serial clock scl output the serial clock to slave peripherals. scl input the serial clock from master. p4.0 sda i/o sda: twi serial data scl is the bidirectional twi data line. p4.1 signal name type description alternate function ss i/o ss : spi slave select p1.1 miso i/o miso: spi master input slave output line when spi is in master mode, miso receives data from the slave peripheral. when spi is in slave mode, miso outputs data to the master controller. p1.5 sck i/o sck: spi serial clock sck outputs clock to the slave peripheral or receive clock from the master p1.6 mosi i/o mosi: spi master output slave input line when spi is in master mode, mosi outputs data to the slave peripheral. when spi is in slave mode, mosi receives data from the master controller p1.7 table 4. timer 0, timer 1 and timer 2 signal description (continued) signal name type description alternate function
8 at89c5131a-l 4338e?usb?06/06 table 8. ports signal description table 9. clock signal description signal name type description alternate function p0[7:0] i/o port 0 p0 is an 8-bit open-drain bidirectional i/o port. port 0 pins that have 1s written to them float and can be used as high impedance inputs. to avoid any parasitic current consumption, floating p0 inputs must be pulled to v dd or v ss . ad[7:0] p1[7:0] i/o port 1 p1 is an 8-bit bidirectional i/o port with internal pull-ups. kin[7:0] t2 t2ex eci cex[4:0] p2[7:0] i/o port 2 p2 is an 8-bit bidirectional i/o port with internal pull-ups. a[15:8] p3[7:0] i/o port 3 p3 is an 8-bit bidirectional i/o port with internal pull-ups. led[3:0] rxd txd int0 int1 t0 t1 wr rd p4[1:0] i/o port 4 p4 is an 2-bit open port. scl sda signal name type description alternate function xtal1 i input to the on-chip inverting oscillator amplifier to use the internal oscillator, a crystal/resonator circuit is connected to this pin. if an external oscillator is used, its output is connected to this pin. - xtal2 o output of the on-chip inverting oscillator amplifier to use the internal oscillator, a crystal/resonator circuit is connected to this pin. if an external oscillator is used, leave xtal2 unconnected. - pllf i pll low pass filter input receives the rc network of the pll low pass filter (see figure 4 on page 11 ). -
9 at89c5131a-l 4338e?usb?06/06 table 10. usb signal description table 11. system signal description signal name type description alternate function d+ i/o usb data + signal set to high level under reset. - d- i/o usb data - signal set to low level under reset. - vref o usb reference voltage connect this pin to d+ using a 1.5 k resistor to use the detach function. - signal name type description alternate function ad[7:0] i/o multiplexed address/data lsb for external access data lsb for slave port access (used for 8-bit and 16-bit modes) p0[7:0] a[15:8] i/o address bus msb for external access data msb for slave port access (used for 16-bit mode only) p2[7:0] rd i/o read signal read signal asserted during external data memory read operation. control input for slave port read access cycles. p3.7 wr i/o write signal write signal asserted during external data memory write operation. control input for slave write access cycles. p3.6 rst i/o reset holding this pin low for 64 oscillator periods while the oscillator is running resets the device. the port pins are driven to their reset conditions when a voltage lower than v il is applied, whether or not the oscillator is running. this pin has an internal pull-up resistor which allows the device to be reset by connecting a capacitor between this pin and vss. asserting rst when the chip is in idle mode or power-down mode returns the chip to normal operation. this pin is set to 0 for at least 12 oscillator periods when an internal reset occurs (hardware watchdog or power monitor). - ale o address latch enable output the falling edge of ale strobes the address into external latch. this signal is active only when reading or writing external memory using movx instructions. - psen o program strobe enable / hardware conditions input for isp used as input under reset to detect external hardware conditions of isp mode - ea i external access enable this pin must be held low to force the device to fetch code from external program memory starting at address 0000h. it is latched during reset and cannot be dynamically changed during operation. -
10 at89c5131a-l 4338e?usb?06/06 table 12. power signal description signal name type description alternate function avss gnd alternate ground avss is used to supply the on-chip pll and the usb pad. - avdd pwr alternate supply voltage avdd is used to supply the on-chip pll and the usb pad. - vss gnd digital ground vss is used to supply the buffer ring and the digital core. - vdd pwr digital supply voltage vdd is used to supply the buffer ring on all versions of the device. it is also used to power the on-chip voltage regulator of the standard versions or the digital core of the low power versions. - vref o usb pull-up controlled output vref is used to control the usb d+ 1.5 k pull up. the vref output is in high impedance when the bit detach is set in the usbcon register. -
11 at89c5131a-l 4338e?usb?06/06 typical application recommended external components all the external components described in the figure below must be implemented as close as possible from the microcontroller package. the following figure represents the typical wiring schematic. figure 4. typical application vss xtal1 xtal2 q 22pf 22pf vss pllf 100r 10nf 2.2nf vss vss avss vss d- d+ 27r 27r vref 1.5k usb d+ d- vbus gnd vss vdd avdd vdd 4.7f vss 100nf vss 100nf vss at89c5131a-l
12 at89c5131a-l 4338e?usb?06/06 pcb recommandations figure 5. usb pads figure 6. usb pll d+ vref d- usb connecto r wires must be routed in parallel and components must be if possible, isolate d+ and d- signals from other signals with ground wires must be as short as possible close to the microcontroller pllf avss components must be isolate filter components with a ground wire microcontroller close to the c2 c1 r
13 at89c5131a-l 4338e?usb?06/06 clock controller introduction the at89c5131a-l clock controller is based on an on-chip oscillator feeding an on-chip phase lock loop (pll). all the internal clocks to the peripherals and cpu core are gen- erated by this controller. the at89c5131a-l x1 and x2 pins are the input and the output of a single-stage on- chip inverter (see figure 7) that can be configured with off-chip components as a pierce oscillator (see figure 8). value of capacitors and crystal characteristics are detailed in the section ?dc characteristics?. the x1 pin can also be used as input for an external 48 mhz clock. the clock controller outputs three different clocks as shown in figure 7: ? a clock for the cpu core ? a clock for the peripherals which is used to generate the timers, pca, wd, and port sampling clocks ? a clock for the usb controller these clocks are enabled or disabled depending on the power reduction mode as detailed in section ?power management?, page 152. figure 7. oscillator block diagram oscillator two clock sources are available for cpu: ? crystal oscillator on x1 and x2 pins: up to 32 mhz ? external 48 mhz clock on x1 pin in order to optimize the power consumption, the oscillator inverter is inactive when the pll output is not selected for the usb device. x1 x2 pd pcon.1 idl pcon.0 peripheral cpu core 0 1 x2 ckcon.0 2 clock clock ext48 pllcon.2 0 1 pll usb clock
14 at89c5131a-l 4338e?usb?06/06 figure 8. crystal connection pll pll description the at89c5131a-l pll is used to generate internal high frequency clock (the usb clock) synchronized with an external low-frequency (the peripheral clock). the pll clock is used to generate the usb interface clock. figure 9 shows the internal structure of the pll. the pfld block is the phase frequency comparator and lock detector. this block makes the comparison between the reference clock coming from the n divider and the reverse clock coming from the r divider and generates some pulses on the up or down signal depending on the edge position of the reverse clock. the pllen bit in pllcon register is used to enable the clock generation. when the pll is locked, the bit plock in pllcon register (see figure 9) is set. the chp block is the charge pump that generates the voltage reference for the vco by injecting or extracting charges from the external filter connected on pllf pin (see figure 10). value of the filter components are detailed in the section ?dc characteristics?. the vco block is the voltage controlled oscillator controlled by the voltage v ref pro- duced by the charge pump. it generates a square wave signal: the pll clock. figure 9. pll block diagram and symbol figure 10. pll filter connection the typical values are: r = 100 , c1 = 10 nf, c2 = 2.2 nf. vss x1 x2 q c1 c2 pllen pllcon.1 n3:0 n divider r divider vco usb clock usbclk osc clk r 1 + () n1 + ---------------------------------------------- - = osc clock pfld plock pllcon.0 pllf chp vref up down r3:0 usb clock usb clock symbo l vss pllf r c1 c2 vss
15 at89c5131a-l 4338e?usb?06/06 pll programming the pll is programmed using the flow shown in figure 11. as soon as clock generation is enabled user must wait until the lock indicator is set to ensure the clock output is stable. figure 11. pll programming flow divider values to generate a 48 mhz clock using the pll, the divider values have to be configured fol- lowing the oscillator frequency. the typical divider values are shown in table 13. table 13. typical divider values pll programming configure dividers n3:0 = xxxxb r3:0 = xxxxb enable pll pllen = 1 pll locked? lock = 1? oscillator frequency r+1 n+1 plldiv 3 mhz 16 1 f0h 6 mhz 8 1 70h 8 mhz 6 1 50h 12 mhz 4 1 30h 16 mhz 3 1 20h 18 mhz 8 3 72h 20 mhz 12 5 b4h 24 mhz 2 1 10h 32 mhz 3 2 21h 40 mhz 12 10 b9h
16 at89c5131a-l 4338e?usb?06/06 registers table 14. ckcon0 (s:8fh) clock control register 0 reset value = 0000 0000b 76543210 twix2 wdx2 pcax2 six2 t2x2 t1x2 t0x2 x2 bit number bit mnemonic description 7twix2 twi clock this control bit is validated when the cpu clock x2 is set. when x2 is low, this bit has no effect. clear to select 6 clock periods per peripheral clock cycle. set to select 12 clock periods per peripheral clock cycle. 6wdx2 watchdog clock this control bit is validated when the cpu clock x2 is set. when x2 is low, this bit has no effect. clear to select 6 clock periods per peripheral clock cycle. set to select 12 clock periods per peripheral clock cycle. 5 pcax2 programmable counter array clock this control bit is validated when the cpu clock x2 is set. when x2 is low, this bit has no effect. clear to select 6 clock periods per peripheral clock cycle. set to select 12 clock periods per peripheral clock cycle. 4six2 enhanced uart clock (mode 0 and 2) this control bit is validated when the cpu clock x2 is set. when x2 is low, this bit has no effect. clear to select 6 clock periods per peripheral clock cycle. set to select 12 clock periods per peripheral clock cycle. 3t2x2 timer2 clock this control bit is validated when the cpu clock x2 is set. when x2 is low, this bit has no effect. clear to select 6 clock periods per peripheral clock cycle. set to select 12 clock periods per peripheral clock cycle. 2t1x2 timer1 clock this control bit is validated when the cpu clock x2 is set. when x2 is low, this bit has no effect. clear to select 6 clock periods per peripheral clock cycle. set to select 12 clock periods per peripheral clock cycle. 1t0x2 timer0 clock this control bit is validated when the cpu clock x2 is set. when x2 is low, this bit has no effect. clear to select 6 clock periods per peripheral clock cycle. set to select 12 clock periods per peripheral clock cycle. 0x2 system clock control bit clear to select 12 clock periods per machine cycle (std mode, f cpu = f per = f osc / 2). set to select 6 clock periods per machine cycle (x2 mode, f cpu = f per = f osc ).
17 at89c5131a-l 4338e?usb?06/06 table 15. ckcon1 (s:afh) clock control register 1 reset value = 0000 0000b table 16. pllcon (s:a3h) pll control register reset value = 0000 0000b table 17. plldiv (s:a4h) pll divider register reset value = 0000 0000 76543210 -------spix2 bit number bit mnemonic description 7-1 - reserved the value read from this bit is always 0. do not set this bit. 0 spix2 spi clock this control bit is validated when the cpu clock x2 is set. when x2 is low, this bit has no effect. clear to select 6 clock periods per peripheral clock cycle. set to select 12 clock periods per peripheral clock cycle. 76543210 -----ext48pllenplock bit number bit mnemonic description 7-3 - reserved the value read from this bit is always 0. do not set this bit. 2 ext48 external 48 mhz enable bit set this bit to bypass the pll and disable the crystal oscillator. clear this bit to select the pll output as usb clock and to enable the crystal oscillator. 1pllen pll enable bit set to enable the pll. clear to disable the pll. 0plock pll lock indicator set by hardware when pll is locked. clear by hardware when pll is unlocked. 76543210 r3 r2 r1 r0 n3 n2 n1 n0 bit number bit mnemonic description 7-4 r3:0 pll r divider bits 3-0 n3:0 pll n divider bits
18 at89c5131a-l 4338e?usb?06/06 sfr mapping the special function registers (sfrs) of the at89c5131a-l fall into the following categories: ? c51 core registers: acc, b, dph, dpl, psw, sp ? i/o port registers: p0, p1, p2, p3, p4 ? timer registers: t2con, t2mod, tcon, th0, th1, th2, tmod, tl0, tl1, tl2, rcap2l, rcap2h ? serial i/o port registers: saddr, saden, sbuf, scon ? pca (programmable counter array) registers: ccon, cmod, ccapmx, cl, ch, ccapxh, ccapxl (x: 0 to 4) ? power and clock control registers: pcon ? hardware watchdog timer registers: wdtrst, wdtprg ? interrupt system registers: ien0, ipl0, iph0, ien1, ipl1, iph1 ? keyboard interface registers: kbe, kbf, kbls ? led register: ledcon ? two wire interface (twi) registers: sscon, sscs, ssdat, ssadr ? serial port interface (spi) registers: spcon, spsta, spdat ? usb registers: uxxx (17 registers) ? pll registers: pllcon, plldiv ? brg (baud rate generator) registers: brl, bdrcon ? flash register: fcon (fcon access is reserved for the flash api and isp software) ? eeprom register: eecon ? others: auxr, auxr1, ckcon0, ckcon1
19 at89c5131a-l 4338e?usb?06/06 the table below shows all sfrs with their address and their reset value. note: 1. fcon access is reserved for the flash api and isp software. table 18. sfr descriptions bit addressable non-bit addressable 0/8 1/9 2/a 3/b 4/c 5/d 6/e 7/f f8h uepint 0000 0000 ch 0000 0000 ccap0h xxxx xxxx ccap1h xxxx xxxx ccap2h xxxx xxxx ccap3h xxxx xxxx ccap4h xxxx xxxx ffh f0h b 0000 0000 ledcon 0000 0000 f7h e8h cl 0000 0000 ccap0l xxxx xxxx ccap1l xxxx xxxx ccap2l xxxx xxxx ccap3l xxxx xxxx ccap4l xxxx xxxx efh e0h acc 0000 0000 ubyctlx 0000 0000 ubycthx 0000 0000 e7h d8h ccon 00x0 0000 cmod 00xx x000 ccapm0 x000 0000 ccapm1 x000 0000 ccapm2 x000 0000 ccapm3 x000 0000 ccapm4 x000 0000 dfh d0h psw 0000 0000 fcon (1) xxxx 0000 eecon xxxx xx00 uepconx 1000 0000 ueprst 0000 0000 d7h c8h t2con 0000 0000 t2mod xxxx xx00 rcap2l 0000 0000 rcap2h 0000 0000 tl2 0000 0000 th2 0000 0000 uepstax 0000 0000 uepdatx 0000 0000 cfh c0h p4 xx xx 1111 uepien 0000 0000 spcon 0001 0100 spsta 0000 0000 spdat xxxx xxxx usbaddr 1000 0000 uepnum 0000 0000 c7h b8h ipl0 x000 000 saden 0000 0000 ufnuml 0000 0000 ufnumh 0000 0000 usbcon 0000 0000 usbint 0000 0000 usbien 0000 0000 bfh b0h p3 1111 1111 ien1 x0xx x000 ipl1 x0xx x000 iph1 x0xx x000 iph0 x000 0000 b7h a8h ien0 0000 0000 saddr 0000 0000 ckcon1 0000 0000 afh a0h p2 1111 1111 auxr1 xxxx x0x0 pllcon xxxx xx00 plldiv 0000 0000 wdtrst xxxx xxxx wdtprg xxxx x000 a7h 98h scon 0000 0000 sbuf xxxx xxxx brl 0000 0000 bdrcon xxx0 0000 kbls 0000 0000 kbe 0000 0000 kbf 0000 0000 9fh 90h p1 1111 1111 sscon 0000 0000 sscs 1111 1000 ssdat 1111 1111 ssadr 1111 1110 97h 88h tcon 0000 0000 tmod 0000 0000 tl0 0000 0000 tl1 0000 0000 th0 0000 0000 th1 0000 0000 auxr xx0x 0000 ckcon0 0000 0000 8fh 80h p0 1111 1111 sp 0000 0111 dpl 0000 0000 dph 0000 0000 pcon 00x1 0000 87h 0/8 1/9 2/a 3/b 4/c 5/d 6/e 7/f reserved
20 at89c5131a-l 4338e?usb?06/06 the special function registers (sfrs) of the at89c5131 fall into the following categories: table 19. c51 core sfrs table 20. i/o port sfrs mnemonicaddname 76543210 acc e0h accumulator b f0h b register psw d0h program status word sp 81h stack pointer lsb of spx dpl 82h data pointer low byte lsb of dptr dph 83h data pointer high byte msb of dptr mnemonicaddname 76543210 p0 80h port 0 p1 90h port 1 p2 a0h port 2 p3 b0h port 3 p4 c0h port 4 (2bits)
21 at89c5131a-l 4338e?usb?06/06 table 21. timer sfr?s mnemonicaddname 76543210 th0 8ch timer/counter 0 high byte tl0 8ah timer/counter 0 low byte th1 8dh timer/counter 1 high byte tl1 8bh timer/counter 1 low byte th2 cdh timer/counter 2 high byte tl2 cch timer/counter 2 low byte tcon 88h timer/counter 0 and 1 control tf1tr1tf0tr0 ie1 it1 ie0 it0 tmod 89h timer/counter 0 and 1 modes gate1 c/t1# m11 m01 gate0 c/t0# m10 m00 t2con c8h timer/counter 2 control tf2 exf2 rclk tclk exen2 tr2 c/t2# cp/rl2# t2mod c9h timer/counter 2 mode t2oe dcen rcap2h cbh timer/counter 2 reload/capture high byte rcap2l cah timer/counter 2 reload/capture low byte wdtrst a6h watchdog timer reset wdtprg a7h watchdog timer program s2 s1 s0 table 22. serial i/o port sfr?s mnemonicaddname 76543210 scon 98h serial control fe/sm0 sm1 sm2 ren tb8 rb8 ti ri sbuf 99h serial data buffer saden b9h slave address mask saddr a9h slave address table 23. baud rate generator sfr?s mnemonicaddname 76543210 brl 9ah baud rate reload bdrcon 9bh baud rate control brr tbck rbck spd src
22 at89c5131a-l 4338e?usb?06/06 table 24. pca sfr?s mnemo- nicaddname 76543210 ccon d8h pca timer/counter control cf cr ccf4 ccf3 ccf2 ccf1 ccf0 cmod d9h pca timer/counter mode cidl wdte cps1 cps0 ecf cl e9h pca timer/counter low byte ch f9h pca timer/counter high byte ccapm0 ccapm1 ccapm2 ccapm3 ccapm4 dah dbh dch ddh deh pca timer/counter mode 0 pca timer/counter mode 1 pca timer/counter mode 2 pca timer/counter mode 3 pca timer/counter mode 4 ecom0 ecom1 ecom2 ecom3 ecom4 capp0 capp1 capp2 capp3 capp4 capn0 capn1 capn2 capn3 capn4 mat0 mat1 mat2 mat3 mat4 tog0 tog1 tog2 tog3 tog4 pwm0 pwm1 pwm2 pwm3 pwm4 eccf0 eccf1 eccf2 eccf3 eccf4 ccap0h ccap1h ccap2h ccap3h ccap4h fah fbh fch fdh feh pca compare capture module 0 h pca compare capture module 1 h pca compare capture module 2 h pca compare capture module 3 h pca compare capture module 4 h ccap0h7 ccap1h7 ccap2h7 ccap3h7 ccap4h7 ccap0h6 ccap1h6 ccap2h6 ccap3h6 ccap4h6 ccap0h5 ccap1h5 ccap2h5 ccap3h5 ccap4h5 ccap0h4 ccap1h4 ccap2h4 ccap3h4 ccap4h4 ccap0h3 ccap1h3 ccap2h3 ccap3h3 ccap4h3 ccap0h2 ccap1h2 ccap2h2 ccap3h2 ccap4h2 ccap0h1 ccap1h1 ccap2h1 ccap3h1 ccap4h1 ccap0h0 ccap1h0 ccap2h0 ccap3h0 ccap4h0 ccap0l ccap1l ccap2l ccap3l ccap4l eah ebh ech edh eeh pca compare capture module 0 l pca compare capture module 1 l pca compare capture module 2 l pca compare capture module 3 l pca compare capture module 4 l ccap0l7 ccap1l7 ccap2l7 ccap3l7 ccap4l7 ccap0l6 ccap1l6 ccap2l6 ccap3l6 ccap4l6 ccap0l5 ccap1l5 ccap2l5 ccap3l5 ccap4l5 ccap0l4 ccap1l4 ccap2l4 ccap3l4 ccap4l4 ccap0l3 ccap1l3 ccap2l3 ccap3l3 ccap4l3 ccap0l2 ccap1l2 ccap2l2 ccap3l2 ccap4l2 ccap0l1 ccap1l1 ccap2l1 ccap3l1 ccap4l1 ccap0l0 ccap1l0 ccap2l0 ccap3l0 ccap4l0 table 25. interrupt sfr?s mnemo- nicaddname 76543210 ien0 a8h interrupt enable control 0 ea ec et2 es et1 ex1 et0 ex0 ien1 b1h interrupt enable control 1 eusb espi etwi ekb ipl0 b8h interrupt priority control low 0 ppcl pt2l psl pt1l px1l pt0l px0l iph0 b7h interrupt priority control high 0 ppch pt2h psh pt1h px1h pt0h px0h ipl1 b2h interrupt priority control low 1 pusbl pspil ptwil pkbl iph1 b3h interrupt priority control high 1 pusbh pspih ptwih pkbh table 26. pll sfrs mnemonicaddname 765432 1 0 pllcon a3h pll control ext48 pllen plock plldiva4hpll divider r3r2r1r0n3n2 n1 n0
23 at89c5131a-l 4338e?usb?06/06 table 27. keyboard sfrs mnemonicaddname 76543210 kbf 9eh keyboard flag register kbf7 kbf6 kbf5 kbf4 kbf3 kbf2 kbf1 kbf0 kbe 9dh keyboard input enable register kbe7 kbe6 kbe5 kbe4 kbe3 kbe2 kbe1 kbe0 kbls 9ch keyboard level selector register kbls7 kbls6 kbls5 kbls4 kbls3 kbls2 kbls1 kbls0 table 28. twi sfrs mnemonicaddname 76543210 sscon 93h synchronous serial control cr2 ssie sta sto si aa cr1 cr0 sscs 94h synchronous serial control-status sc4sc3sc2sc1sc0 - - - ssdat 95h synchronous serial data sd7 sd6 sd5 sd4 sd3 sd2 sd1 sd0 ssadr 96h synchronous serial address a7 a6 a5 a4 a3 a2 a1 a0 table 29. spi sfrs mnemonicaddname 76543210 spcon c3h serial peripheral control spr2 spen ssdis mstr cpol cpha spr1 spr0 spsta c4h serial peripheral status-control spif wcol sserr modf - - - - spdat c5h serial peripheral data r7 r6 r5 r4 r3 r2 r1 r0 table 30. usb sfr?s mnemonicaddname 76543210 usbcon bch usb global control usbe suspclk sdrmwup detach uprsm rmwupe confg fadden usbaddr c6h usb address fen uadd6 uadd5 uadd4 uadd3 uadd2 uadd1 uadd0 usbint bdh usb global interrupt - - wupcpu eorint sofint - - spint usbien beh usb global interrupt enable - - ewupcpu eeorint esofint - - espint uepnum c7h usb endpoint number - - - - epnum3 epnum2 epnum1 epnum0 uepconx d4h usb endpoint x control epen - - - dtgl epdir eptype1 eptype0 uepstax ceh usb endpoint x status dir rxoutb1 stallrq txrdy stlcrc rxsetup rxoutb0 txcmp ueprst d5h usb endpoint reset - ep6rst ep5rst ep4rst ep3rst ep2rst ep1rst ep0rst uepint f8h usb endpoint interrupt - ep6int ep5int ep4int ep3int ep2int ep1int ep0int
24 at89c5131a-l 4338e?usb?06/06 uepien c2h usb endpoint interrupt enable - ep6inte ep5inte ep4inte ep3inte ep2inte ep1inte ep0inte uepdatx cfh usb endpoint x fifo data fdat7 fdat6 fdat5 fdat4 fdat3 fdat2 fdat1 fdat0 ubyctlx e2h usb byte counter low (ep x) byct7 byct6 byct5 byct4 byct3 byct2 byct1 byct0 ubycthx e3h usb byte counter high (ep x) -----byct10byct9byct8 ufnuml bah usb frame number low fnum7 fnum6 fnum5 fnum4 fnum3 fnum2 fnum1 fnum0 ufnumh bbh usb frame number high - - crcok crcerr - fnum10 fnum9 fnum8 table 30. usb sfr?s mnemonicaddname 76543210 table 31. other sfr?s mnemonicaddname 76543210 pcon 87h power control smod1 smod0 - pof gf1 gf0 pd idl auxr 8eh auxiliary register 0 dpu - m0 - xrs1 xrs2 extram a0 auxr1 a2h auxiliary register 1 - - enboot - gf3 - - dps ckcon0 8fh clock control 0 twix2 wdx2 pcax2 six2 t2x2 t1x2 t0x2 x2 ckcon1 afh clock control 1 - - - - - - - spix2 ledcon f1h led control led3 led2 led1 led0 fcon d1h flash control fpl3 fpl2 fpl1 fpl0 fps fmod1 fmod0 fbusy eecon d2h eeprom contol eepl3 eepl2 eepl1 eepl0 - - eee eebusy
25 at89c5131a-l 4338e?usb?06/06 dual data pointer register the additional data pointer can be used to speed up code execution and reduce code size. the dual dptr structure is a way by which the chip will specify the address of an exter- nal data memory location. there are two 16-bit dptr registers that address the external memory, and a single bit called dps = auxr1.0 (see table 32) that allows the program code to switch between them (see figure 12). figure 12. use of dual pointer table 32. auxr1 register auxr1- auxiliary register 1(0a2h) reset value = xx[bljb ]x x0x0b not bit addressable a. bit 2 stuck at 0; this allows to use inc auxr1 to toggle dps without changing gf3. external data memory auxr1(a2h) dps dph(83h) dpl(82h) 0 7 dptr0 dptr1 76543210 - - enboot - gf3 0 - dps bit number bit mnemonic description 7- reserved the value read from this bit is indeterminate. do not set this bit. 6- reserved the value read from this bit is indeterminate. do not set this bit. 5 enboot enable boot flash cleared to disable boot rom. set to map the boot rom between f800h - 0ffffh. 4- reserved the value read from this bit is indeterminate. do not set this bit. 3 gf3 this bit is a general-purpose user flag. 2 0 always cleared. 1- reserved the value read from this bit is indeterminate. do not set this bit. 0dps data pointer selection cleared to select dptr0. set to select dptr1.
26 at89c5131a-l 4338e?usb?06/06 assembly language ; block move using dual data pointers ; modifies dptr0, dptr1, a and psw ; note: dps exits opposite of entry state ; unless an extra inc auxr1 is added ; 00a2 auxr1 equ 0a2h ; 0000 909000mov dptr,#source ; address of source 0003 05a2 inc auxr1 ; switch data pointers 0005 90a000 mov dptr,#dest ; address of dest 0008 loop: 0008 05a2 inc auxr1 ; switch data pointers 000a e0 movx a,@dptr ; get a byte from source 000b a3 inc dptr ; increment source address 000c 05a2 inc auxr1 ; switch data pointers 000e f0 movx @dptr,a ; write the byte to dest 000f a3 inc dptr ; increment dest address 0010 70f6jnz loop ; check for 0 terminator 0012 05a2 inc auxr1 ; (optional) restore dps inc is a short (2 bytes) and fast (12 clocks) way to manipulate the dps bit in the auxr1 sfr. however, note that the inc instruction does not directly force the dps bit to a par- ticular state, but simply toggles it. in simple routines, such as the block move example, only the fact that dps is toggled in the proper sequence matters, not its actual value. in other words, the block move routine works the same whether dps is '0' or '1' on entry. observe that without the last instruction (inc auxr1), the routine will exit with dps in the opposite state.
27 at89c5131a-l 4338e?usb?06/06 program/code memory the at89c5131a-l implement 32 kbytes of on-chip program/code memory. figure 13 shows the split of internal and external program/code memory spaces depending on the product. the flash memory increases eprom and rom functionality by in-circuit electrical era- sure and programming. thanks to the internal charge pump, the high voltage needed for programming or erasing flash cells is generated on-chip using the standard v dd volt- age. thus, the flash memory can be programmed using only one voltage and allows in- application software programming commonly known as iap. hardware programming mode is also available using specific programming tool. figure 13. program/code memory organization note: if the program executes exclusively from on-chip code memory (not from external mem- ory), beware of executing code from the upper byte of on-chip memory (7fffh) and thereby disrupting i/o ports 0 and 2 due to external prefetch. fetching code constant from this location does not affect ports 0 and 2. external code memory access memory interface the external memory interface comprises the external bus (port 0 and port 2) as well as the bus control signals (psen , and ale). figure 14 shows the structure of the external address bus. p0 carries address a7:0 while p2 carries address a15:8. data d7:0 is multiplexed with a7:0 on p0. table 33 describes the external memory interface signals. figure 14. external code memory interface structure 0000h 32 kbytes 7fffh flash 32 kbytes external code ffffh at89c5131a-l 8000h flash eprom at89c5131 p2 p0 ad7:0 a15:8 a7:0 a15:8 d7:0 a7:0 ale latch oe psen
28 at89c5131a-l 4338e?usb?06/06 table 33. external data memory interface signals external bus cycles this section describes the bus cycles the at89c5131a-l executes to fetch code (see figure 15) in the external program/code memory. external memory cycle takes 6 cpu clock periods. this is equivalent to 12 oscillator clock periods in standard mode or 6 oscillator cl ock periods in x2 mode. for further information on x2 mode (see the clock section). for simplicity, the accompanying figure depicts the bus cycle waveforms in idealized form and do not provide precise timing information. figure 15. external code fetch waveforms flash memory architecture at89c5131a-l features two on-chip flash memories: ? flash memory fm0: containing 32 kbytes of program memory (user space) organized into 128-byte pages, ? flash memory fm1: 3 kbytes for bootloader and application programming interfaces (api). the fm0 supports both parallel programming and serial in-system programming (isp) whereas fm1 supports only parallel programming by programmers. the isp mode is detailed in the ?in-system programming? section. all read/write access operations on flash memory by user application are managed by a set of api described in the ?in-system programming? section. signal name type description alternate function a15:8 o address lines upper address lines for the external bus. p2.7:0 ad7:0 i/o address/data lines multiplexed lower address lines and data for the external memory. p0.7:0 ale o address latch enable ale signals indicates that valid address information are available on lines ad7:0. - psen o program store enable output this signal is active low during external code fetch or external code read (movc instruction). - ale p0 p2 psen pcl pch pch pcl d7:0 d7:0 pch d7:0 c pu clock
29 at89c5131a-l 4338e?usb?06/06 figure 16. flash memory architecture fm0 memory architecture the flash memory is made up of 4 blocks (see figure 16): 1. the memory array (user space) 32 kbytes 2. the extra row 3. the hardware security bits 4. the column latch registers user space this space is composed of a 32 kbytes flash memory organized in 256 pages of 128 bytes. it contains the user?s application code. extra row (xrow) this row is a part of fm0 and has a size of 128 bytes. the extra row contains informa- tion for bootloader usage. (see table 39.software registers, page 39) hardware security space the hardware security space is a part of fm0 and has a size of 1 byte. the 4 msb can be read/written by software. the 4 lsb can only be read by software and written by hardware in parallel mode. column latches the column latches, also part of fm0, have a size of full page (128 bytes). the column latches are the entrance buffers of the three previous memory locations (user array, xrow and hardware security byte). overview of fm0 operations the cpu interfaces to the flash memory through the fcon register and auxr1 register. these registers are used to: ? map the memory spaces in the adressable space ? launch the programming of the memory spaces ? get the status of the flash memory (busy/not busy) ? select the flash memory fm0/fm1. mapping of the memory space by default, the user space is accessed by movc instruction for read only. the column latches space is made accessible by setting the fps bit in fcon register. writing is possible from 0000h to 7fffh, address bits 6 to 0 are used to select an address within a page while bits 14 to 7 are used to select the programming address of the page. setting this bit takes precedence on the extram bit in auxr register. 7fffh 32 kbytes flash memory fm0 0000h hardware security (1 byte) column latches (128 bytes) user space extra row (128 bytes) 3 kbytes flash memory fm1 boot space ffffh f400h fm1 mapped between ffffh and f400h when bit enboot is set in auxr1 register
30 at89c5131a-l 4338e?usb?06/06 the other memory spaces (user, extra row, hardware security) are made accessible in the code segment by programming bits fmod0 and fmod1 in fcon register in accor- dance with table 34. a movc instruction is then used for reading these spaces. table 34. fm0 blocks select bits launching programming fpl3:0 bits in fcon register are used to secure the launch of programming. a specific sequence must be written in these bits to unlock the write protection and to launch the programming. this sequence is 5 followed by a. table 35 summarizes the memory spaces to program according to fmod1:0 bits. table 35. programming spaces the flash memory enters a busy state as soon as programming is launched. in this state, the memory is not available for fetching code. thus to avoid any erratic execution during programming, the cpu enters idle mode. exit is automatically performed at the end of programming. note: interrupts that may occur during programming time must be disabled to avoid any spuri- ous exit of the idle mode. status of the flash memory the bit fbusy in fcon register is used to indicate the status of programming. fbusy is set when programming is in progress. selecting fm0/fm1 the bit enboot in auxr1 register is used to choose between fm0 and fm1 mapped up to f800h. fmod1 fmod0 fm0 adressable space 0 0 user (0000h-ffffh) 0 1 extra row(ff80h-ffffh) 1 0 hardware security (0000h) 11reserved write to fcon operation fpl3:0 fps fmod1 fmod0 user 5 x 0 0 no action ax0 0 write the column latches in user space extra row 5 x 0 1 no action ax0 1 write the column latches in extra row space security space 5 x 1 0 no action a x 1 0 write the fuse bits space reserved 5 x 1 1 no action a x 1 1 no action
31 at89c5131a-l 4338e?usb?06/06 loading the column latches any number of data from 1 byte to 128 bytes can be loaded in the column latches. this provides the capability to program the whole memory by byte, by page or by any number of bytes in a page. when programming is launched, an automatic erase of the locations loaded in the col- umn latches is first performed, then programming is effectively done. thus, no page or block erase is needed and only the loaded data are programmed in the corresponding page. the following procedure is used to load the column latches and is summarized in figure 17: ? map the column latch space by setting fps bit. ? load the dptr with the address to load. ? load accumulator register with the data to load. ? execute the movx @dptr, a instruction. ? if needed loop the three last instructions until the page is completely loaded. figure 17. column latches loading procedure programming the flash spaces user the following procedure is used to program the user space and is summarized in figure 18: ? load data in the column latches from address 0000h to 7fffh (1) . ? disable the interrupts. ? launch the programming by writing the data sequence 50h followed by a0h in fcon register. the end of the programming indicated by the fbusy flag cleared. ? enable the interrupts. note: 1. the last page address used when loading the column latch is the one used to select the page programming address. column latches loading data load dptr = address acc = data exec: movx @dptr, a last byte to load? column latches mapping fps = 1 data memory mapping fps = 0
32 at89c5131a-l 4338e?usb?06/06 extra row the following procedure is used to program the extra row space and is summarized in figure 18: ? load data in the column latches from address ff80h to ffffh. ? disable the interrupts. ? launch the programming by writing the data sequence 52h followed by a2h in fcon register. the end of the programming indicated by the fbusy flag cleared. ? enable the interrupts. figure 18. flash and extra row programming procedure flash spaces programming disable it ea = 0 launch programming fcon = 5xh fcon = axh end programming enable it ea = 1 column latches loading see figure 17 fbusy cleared? erase mode fcon = 00h
33 at89c5131a-l 4338e?usb?06/06 hardware security the following procedure is used to program the hardware security space and is sum- marized in figure 19: ? set fps and map hardware byte (fcon = 0x0c) ? disable the interrupts. ? load dptr at address 0000h. ? load accumulator register with the data to load. ? execute the movx @dptr, a instruction. ? launch the programming by writing the data sequence 54h followed by a4h in fcon register. the end of the programming indicated by the fbusy flag cleared. ? enable the interrupts. figure 19. hardware programming procedure flash spaces programming disable it ea = 0 launch programming fcon = 54h fcon = a4h end programming enable it ea = 1 fbusy cleared? erase mode fcon = 00h data load dptr = 00h acc = data exec: movx @dptr, a fcon = 0ch
34 at89c5131a-l 4338e?usb?06/06 reading the flash spaces user the following procedure is used to read the user space and is summarized in figure 20: ? map the user space by writing 00h in fcon register. ? read one byte in accumulator by executing movc a, @a+dptr with a = 0 & dptr = 0000h to ffffh. extra row the following procedure is used to read the extra row space and is summarized in figure 20: ? map the extra row space by writing 02h in fcon register. ? read one byte in accumulator by executing movc a, @a+dptr with a = 0 & dptr = ff80h to ffffh. hardware security the following procedure is used to read the hardware security space and is summa- rized in figure 20: ? map the hardware security space by writing 04h in fcon register. ? read the byte in accumulator by executing movc a, @a+dptr with a = 0 & dptr = 0000h. figure 20. reading procedure flash spaces reading flash spaces mapping fcon = 00000xx0b data read dptr = address acc = 0 exec: movc a, @a+dptr erase mode fcon = 00h
35 at89c5131a-l 4338e?usb?06/06 registers table 36. fcon (s:d1h) flash control register reset value = 0000 0000b 76543210 fpl3 fpl2 fpl1 fpl0 fps fmod1 fmod0 fbusy bit number bit mnemonic description 7-4 fpl3:0 programming launch command bits write 5xh followed by axh to launch the programming according to fmod1:0. (see table 35.) 3fps flash map program space set to map the column latch space in the data memory space. clear to re-map the data memory space. 2-1 fmod1:0 flash mode see table 34 or table 35. 0 fbusy flash busy set by hardware when programming is in progress. clear by hardware when programming is done. can not be cleared by software.
36 at89c5131a-l 4338e?usb?06/06 flash eeprom memory general description the flash memory increases eprom functionality with in-circuit electrical erasure and programming. it contains 32 kbytes of program memory organized in 256 pages of 128 bytes, respectively. this memory is both parallel and serial in-system programmable (isp). isp allows devices to alter their own program memory in the actual end product under software control. a default serial loader (bootloader) program allows isp of the flash. the programming does not require 12v external programming voltage. the necessary high programming voltage is generated on-chip using the standard v cc pins of the microcontroller. features ? flash eeprom internal program memory. ? boot vector allows user-provided flash loader code to reside anywhere in the flash memory space. this configuration provides flexibility to the user. ? default loader in boot eeprom allows programming via the serial port without the need of a user provided loader. ? up to 64k bytes external program memory if the internal program memory is disabled (ea = 0). ? programming and erase voltage with standard power supply. ? read/program/erase: ? byte-wise read (without wait state). ? byte or page erase and programming (10 ms). ? typical programming time (32 kbytes) in 10 sec. ? parallel programming with 87c51 compatible hardware interface to programmer. ? programmable security for the code in the flash. ? 100k write cycles ? 10 years data retention flash programming and erasure the 32 kbytes flash is programmed by bytes or by pages of 128 bytes. it is not neces- sary to erase a byte or a page before programming. the programming of a byte or a page includes a self erase before programming. there are three methods of programming the flash memory: 1. the on-chip isp bootloader may be invok ed which will use low level routines to program the pages. the interface used for serial downloading of flash is the usb. 2. the flash may be programmed or erased in the end-user application by calling low-level routines through a common entry point in the boot flash. 3. the flash may be programmed using the parallel method . the bootloader and the application programming interface (api) routines are located in the flash bootloader.
37 at89c5131a-l 4338e?usb?06/06 flash registers and memory map the at89c5131a-l flash memory uses several registers: ? hardware register can be accessed with a parallel programmer.some bits of the hardware register can be changed, also, by api (i.e. x2 and bljb bits of hardware security byte) or isp. ? software registers are in a special page of the flash memory which can be accessed through the api or with the parallel programming modes. this page, called ?extra flash memory?, is not in the internal flash program memory addressing space. hardware registers the only hardware register of the at89c5131a-l is called hardware security byte (hsb). bootloader jump bit (bljb) one bit of the hsb, the bljb bit, is used to force the boot address: ? when this bit is set the boot address is 0000h. ? when this bit is reset the boot address is f400h. by default, this bit is cleared and the isp is enabled. flash memory lock bits the three lock bits provide different levels of protection for the on-chip code and data, when programmed as shown in table 38. table 37. hardware security byte (hsb) 76543210 x2 bljb oscon1 oscon0 - lb2 lb1 lb0 bit number bit mnemonic description 7x2 x2 mode cleared to force x2 mode (6 clocks per instruction) set to force x1 mode, standard mode (default). 6bljb bootloader jump bit set this bit to start the user?s application on next reset at address 0000h. cleared this bit to start the bootloader at address f400h (default). 5-4 oscon1-0 oscillator control bits these two bits are used to control the oscillator in order to reduce consumption. oscon1 oscon0 description 1 1 the oscillator is configured to run from 0 to 32 mhz 1 0 the oscillator is configured to run from 0 to 16 mhz 0 1 the oscillator is configured to run from 0 to 8 mhz 0 0 this configuration shouldn?t be set 3- reserved 2-0 lb2-0 user memory lock bits see table 38
38 at89c5131a-l 4338e?usb?06/06 table 38. program lock bits notes: 1. u: unprogrammed or ?one? level. 2. p: programmed or ?zero? level. 3. x: don?t care 4. warning: security level 2 and 3 should only be programmed after verification. these security bits protect the code access through the parallel programming interface. they are set by default to level 4. the code access through the isp is still possible and is controlled by the ?software security bits? which are stored in the extra flash memory accessed by the isp firmware. to load a new application with the parallel programmer, a chip erase must be done first. this will set the hsb in its inactive state and will erase the flash memory. the part ref- erence can always be read using flash parallel programming modes. default values the default value of the hsb provides parts ready to be programmed with isp: ? bljb: cleared to force isp operation. ? x2: set to force x1 mode (standard mode) ? oscon1-0: set to start with 32 mhz oscillator configuration value. ? lb2-0: security level four to protect the code from a parallel access with maximum security. software registers several registers are used, in factory and by parallel programmers, to make copies of hardware registers contents. these values are used by atmel isp (see section ?in-sys- tem programming (isp)?). these registers are in the ?extra flash memory? part of the flash memory. this block is also called ?xaf? or extra array flash. they are accessed in the following ways: ? commands issued by the parallel memory programmer. ? commands issued by the isp software. ? calls of api issued by the application software. several software registers are described in table 39. program lock bits protection description security level lb0 lb1 lb2 1 u u u no program lock features enabled. 2puu movc instruction executed from external program memory is disabled from fetching code bytes from any internal memory, ea is sampled and latched on reset, and further parallel programming of the flash and of the eeprom (boot and xdata) is disabled. isp and software programming with api are still allowed. 3xpu same as 2, also verify through parallel programming interface is disabled and serial programming isp is still allowed. 4 x x p same as 3, also external execution is disabled.
39 at89c5131a-l 4338e?usb?06/06 table 39. software registers after programming the part by isp, the bsb must be cleared (00h) in order to allow the application to boot at 0000h. the content of the software security byte (ssb) is described in table 40 and table 41. to assure code protection from a parallel access, the hsb must also be at the required level. the two lock bits provide different levels of protection for the on-chip code and data, when programmed as shown to table 41. address mnemonic description default value 01 sbv software boot vector ffh ? 00 bsb boot status byte 0ffh ? 05 ssb software security byte ffh ? 30 ? copy of the manufacturer code 58h atmel 31 ? copy of the device id #1: family code d7h c51 x2, electrically erasable 60 ? copy of the device id #2: memories f7h at89c5131a-l 32 kbyte 61 ? copy of the device id #3: name dfh at89c5131a-l 32 kbyte, revision 0 table 40. software security byte (ssb) 76543210 ------lb1lb0 bit number bit mnemonic description 7- reserved do not clear this bit. 6- reserved do not clear this bit. 5- reserved do not clear this bit. 4- reserved do not clear this bit. 3- reserved do not clear this bit. 2- reserved do not clear this bit. 1-0 lb1-0 user memory lock bits see table 41
40 at89c5131a-l 4338e?usb?06/06 table 41. program lock bits of the ssb notes: 1. u: unprogrammed or "one" level. 2. p: programmed or ?zero? level. 3. warning: security level 2 and 3 should only be programmed after flash and code verification. flash memory status at89c5131a-l parts are delivered with the isp boot in the flash memory. after isp or parallel programming, the possible contents of the flash memory are summarized in figure 21: figure 21. flash memory possible contents memory organization in the at89c5131a-l, the lowest 32k of the 64 kbyte program memory address space is filled by internal flash. when the ea is pin high, the processor fetches instructions from internal program flash. bus expansion for accessing program memory from 32k upward is automatic since external instruction fetches occur automatically when the program counter exceeds 7fffh (32k). if the ea pin is tied low, all program memory fetches are from external memory. if all storage is on chip, then byte location 7fffh (32k) should be left vacant to prevent and undesired pre-fetch from external program memory address 8000h (32k). program lock bits protection description security level lb0 lb1 1 u u no program lock features enabled. 2 p u isp programming of the flash is disabled. 3 p p same as 2, also verify through isp programming interface is disabled. 0000h virgin default virgin after isp after parallel programming after parallel programming after parallel programming application application after isp or dedicated isp dedicated isp 7fffh at89c5131a-m application virgin or application virgin or application
41 at89c5131a-l 4338e?usb?06/06 eeprom data memory description the 1-kbyte on-chip eeprom memory block is located at addresses 0000h to 03ffh of the eram memory space and is selected by setting control bits in the eecon register. a read in the eeprom memory is done with a movx instruction. a physical write in the eeprom memory is done in two steps: write data in the column latches and transfer of all data latches into an eeprom memory row (programming). the number of data written on the page may vary from 1 to 128 bytes (the page size). when programming, only the data written in the column latch is programmed and a ninth bit is used to obtain this feature. this provides the capability to program the whole mem- ory by bytes, by page or by a number of bytes in a page. indeed, each ninth bit is set when the writing the corresponding byte in a row and all these ninth bits are reset after the writing of the complete eeprom row. write data in the column latches data is written by byte to the column latches as for an external ram memory. out of the 11 address bits of the data pointer, the 4 msbs are used for page selection (row) and 7 are used for byte selection. between two eeprom programming sessions, all the addresses in the column latches must stay on the same page, meaning that the 4 msb must not be changed. the following procedure is used to write to the column latches: ? set bit eee of eecon register ? load dptr with the address to write ? store a register with the data to be written ? execute a movx @dptr, a ? if needed, loop the three last instructions until the end of a 128 bytes page programming the eeprom programming consists on the following actions: ? writing one or more bytes of one page in the column latches. normally, all bytes must belong to the same page; if not, the first page address will be latched and the others discarded. ? launching programming by writing the control sequence (52h followed by a2h) to the eecon register. ? eebusy flag in eecon is then set by hardware to indicate that programming is in progress and that the eeprom segment is not available for reading. ? the end of programming is indicated by a hardware clear of the eebusy flag. read data the following procedure is used to read the data stored in the eeprom memory: ? set bit eee of eecon register ? stretch the movx to accommodate the slow access time of the column latch (set bit m0 of auxr register) ? load dptr with the address to read ? execute a movx a, @dptr
42 at89c5131a-l 4338e?usb?06/06 registers reset value = xxxx xx00b not bit addressable table 42. eecon (s:0d2h) eecon register 76543210 eepl3 eepl2 eepl1 eepl0 - - eee eebusy bit number bit mnemonic description 7-4 eepl3-0 programming launch command bits write 5xh followed by axh to eepl to launch the programming. 3- reserved the value read from this bit is indeterminate. do not set this bit. 2- reserved the value read from this bit is indeterminate. do not set this bit. 1 eee enable eeprom space bit set to map the eeprom space during movx instructions (write in the column latches) clear to map the eram space during movx. 0 eebusy programming busy flag set by hardware when programming is in progress. cleared by hardware when programming is done. cannot be set or cleared by software.
43 at89c5131a-l 4338e?usb?06/06 in-system programming (isp) with the implementation of the user space (fm0) and the boot space (fm1) in flash technology the at89c5131 allows the system engineer the development of applications with a very high level of flexibility. this flexibility is based on the possibility to alter the customer program at any stages of a product?s life: ? before mounting the chip on the pcb, fm0 flash can be programmed with the application code. fm1 is always preprogrammed by atmel with a usb bootloader. (1) ? once the chip is mounted on the pcb, it can be programmed by serial mode via the usb bus. note: 1. the user can also program his own bootloader in fm1. this isp allows code modification over the total lifetime of the product. besides the default bootloaders atmel provide customers all the needed application- programming-interfaces (api) which are needed for the isp. the api are located in the boot memory. this allow the customer to have a full use of the 32-kbyte user memory. flash programming and erasure there are three methods for programming the flash memory: ? the atmel bootloader located in fm1 is activated by the application. low level api routines (located in fm1)will be used to program fm0. the interface used for serial downloading to fm0 is the usb. api can be called also by user?s bootloader located in fm0 at [sbv]00h. ? a further method exist in activating the atmel boot loader by hardware activation. see the section ?hardware registers?. ? the fm0 can be programmed also by the parallel mode using a programmer. figure 22. flash memory mapping f400h 7fffh 32k bytes flash memory 3k bytes iap bootloader fm0 fm1 custom bootloader [sbv]00h ffffh fm1 mapped between f400h and ffff h when api called 0000h
44 at89c5131a-l 4338e?usb?06/06 boot process software boot process example many algorithms can be used for the software boot process. below are descriptions of the different flags and bytes. boot loader jump bit (bljb): - this bit indicates if on reset the user wants to jump to this application at address @0000h on fm0 or execute the boot loader at address @f400h on fm1. - bljb = 0 (i.e. bootloader fm1 executed after a reset) is the default atmel factory pro- gramming. -to read or modify this bit, the apis are used. boot vector address (sbv): - this byte contains the msb of the user boot loader address in fm0. - the default value of sbv is ffh (no user boot loader in fm0). - to read or modify this byte, the apis are used. extra byte (eb) & boot status byte (bsb): - these bytes are reserved for customer use. - to read or modify these bytes, the apis are used. figure 23. hardware boot process algorithm reset bljb == 0 ? hardware software bootloader in fm1 application in fm0 bit enboot in auxr1 register is initialized with bljb inverted. enboot = 0 pc = 0000h enboot = 1 pc = f400h example, if bljb=0, enboot is set (=1) during reset, thus the bootloader is executed after the reset.
45 at89c5131a-l 4338e?usb?06/06 application- programming-interface several application program interface (api) calls are available for use by an application program to permit selective erasing and programming of flash pages. all calls are made by functions. all these apis are described in detail in the following document on the atmel web site. ? datasheet bootloader usb at89c5131. xrow bytes the extra row (xrow) includes 128 bytes. some of these bytes are used for spe- cific purpose in conjonction with the bootloader. table 43. xrow mapping hardware conditions it is possible to force the controller to execute the bootloader after a reset with hard- ware conditions. depending on the product type (low pin count or high pin count package), there are two methods to apply the hardware conditions. high pin count hardware conditions (plcc52, qfp64) for high pin count packages, the hardware conditons (ea = 1, psen = 0) are sampled during the reset rising edge to force the on-chip bootloader execution (see figure 81 on page 172). in this way the bootloader can be carried out regardless of the user flash memory content. as psen is an output port in normal operating mode (running user application or boot- loader code) after reset, it is recommended to release psen after rising edge of reset signal. low pin count hardware conditions (soic28) low pin count products do not have psen signal, thus for these products, the boot- loader is always executed after reset thanks to the bljb bit. the hardware condition are detected at the begining of the bootloader execution from reset. the default factory hardware condition is assigned to port p1. ? p1 must be equal to feh in order to offer the best flexibility, the user can define its own hardware condition on one of the following ports: ?port1 ?port3 ? port4 (only bit0 and bit1) the hardware condition configuration are stored in three bytes called p1_cf, p3_cf, p4_cf. description default value address copy of the manufacturer code 58h 30h copy of the device id#1: family code d7h 31h copy of the device id#2: memories size and type bbh 60h copy of the device id#3: name and revision ffh 61h
46 at89c5131a-l 4338e?usb?06/06 these bytes can be modified by the user through a set of api or through an isp command. note: 1. the bljb must be at 0 (programmed) to be able to restart the bootloader. 2. bljb can always be changed by the means of api, whether it's a low or high pin count package.but for a low pin count version, if bljb=1, no isp via the bootloader is further possible (because the hw conditions are never evaluated, as described in the usb bootloader datasheet). to go back to isp, bljb needs to be changed by a parallel programmer(or by the apis). see a detailed description in the applicable document. ? datasheet bootloader usb at89c5131.
47 at89c5131a-l 4338e?usb?06/06 on-chip expanded ram (eram) the at89c5131a-l provides additional bytes of random access memory (ram) space for increased data parameters handling and high level language usage. at89c5131a-l devices have an expanded ram in the external data space; maximum size and location are described in table 44. the at89c5131a-l has on-chip data memory which is mapped into the following four separate segments. 1. the lower 128 bytes of ram (addresses 00h to 7fh) are directly and indirectly addressable. 2. the upper 128 bytes of ram (addresses 80h to ffh) are indirectly addressable only. 3. the special function registers, sfrs, (addresses 80h to ffh) are directly addressable only. 4. the expanded ram bytes are indirectly accessed by movx instructions, and with the extram bit cleared in the auxr register (see table 44) the lower 128 bytes can be accessed by either direct or indirect addressing. the upper 128 bytes can be accessed by indirect addressing only. the upper 128 bytes occupy the same address space as the sfr. that means they have the same address, but are physically separate from sfr space. figure 24. internal and external data memory address table 44. description of expanded ram part number eram size address start end at89c5131a-l 1024 00h 3ffh eram upper 128 bytes internal ram lower 128 bytes internal ram special function register 80h 80h 00 0ffh or 3ffh(*) 0ffh 00 0ffh external data memory 0000 00ffh up to 03ffh (*) 0ffffh indirect accesses direct accesses direct or indirect accesses 7fh (*) depends on xrs1..0
48 at89c5131a-l 4338e?usb?06/06 when an instruction accesses an internal location above address 7fh, the cpu knows whether the access is to the upper 128 bytes of data ram or to sfr space by the addressing mode used in the instruction. ? instructions that use direct addressing access sfr space. for example: mov 0a0h, # data, accesses the sfr at location 0a0h (which is p2). ? instructions that use indirect addressing access the upper 128 bytes of data ram. for example: mov atr0, # data where r0 contains 0a0h, accesses the data byte at address 0a0h, rather than p2 (whose address is 0a0h). ? the eram bytes can be accessed by indirect addressing, with extram bit cleared and movx instructions. this part of memory which is physically located on-chip, logically occupies the first bytes of external data memory. the bits xrs0 and xrs1 are used to hide a part of the available eram as explained in table 44. this can be useful if external peripherals are mapped at addresses already used by the internal eram. ? with extram = 0, the eram is indirectly addressed, using the movx instruction in combination with any of the registers r0, r1 of the selected bank or dptr. an access to eram will not affect ports p0, p2, p3.6 (wr) and p3.7 (rd). for example, with extram = 0, movx atr0, # data where r0 contains 0a0h, accesses the eram at address 0a0h rather than external memory. an access to external data memory locations higher than the accessible size of the eram will be performed with the movx dptr instructions in the same way as in the standard 80c51, with p0 and p2 as data/address busses, and p3.6 and p3.7 as write and read timing signals. accesses to eram above 0ffh can only be done by the use of dptr. ? with extram = 1 , movx @ri and movx @dptr will be similar to the standard 80c51. movx at ri will provide an eight-bit address multiplexed with data on port0 and any output port pins can be used to output higher order address bits. this is to provide the external paging capability. movx @dptr will generate a sixteen-bit address. port2 outputs the high-order eight address bits (the contents of dph) while port0 multiplexes the low-order eight address bits (dpl) with data. movx at ri and movx @dptr will generate either read or write signals on p3.6 (wr ) and p3.7 (rd ). the stack pointer (sp) may be located anywhere in the 256 bytes ram (lower and upper ram) internal data memory. the stack may not be located in the eram. the m0 bit allows to stretch the eram timings; if m0 is set, the read and write pulses are extended from 6 to 30 clock periods. this is useful to access external slow peripherals.
49 at89c5131a-l 4338e?usb?06/06 reset value = 0x0x 1100b not bit addressable table 45. auxr register auxr - auxiliary register (8eh) 76543210 dpu - m0 - xrs1 xrs0 extram ao bit number bit mnemonic description 7dpu disable weak pull up cleared to enabled weak pull up on standard ports. set to disable weak pull up on standard ports. 6- reserved the value read from this bit is indeterminate. do not set this bit 5m0 pulse length cleared to stretch movx control: the rd and the wr pulse length is 6 clock periods (default). set to stretch movx control: the rd and the wr pulse length is 30 clock periods. 4- reserved the value read from this bit is indeterminate. do not set this bit 3xrs1 eram size xrs1 xrs0 eram size 0 0 256 bytes 0 1 512 bytes 1 0 768 bytes 1 1 1024 bytes (default) 2xrs0 1 extram extram bit cleared to access internal eram using movx at ri at dptr. set to access external memory. 0ao ale output bit cleared, ale is emitted at a constant rate of 1/6 the oscillator frequency (or 1/3 if x2 mode is used) (default). set, ale is active only when a movx or movc instruction is used.
50 at89c5131a-l 4338e?usb?06/06 timer 2 the timer 2 in the at89c5131a-l is the standard c52 timer 2. it is a 16-bit timer/counter: the count is maintained by two cascaded eight-bit timer registers, th2 and tl2. it is controlled by t2con (table 46) and t2mod (table 47) registers. timer 2 operation is similar to timer 0 and timer 1. c/t2 selects f osc /12 (timer operation) or external pin t2 (counter operation) as the timer clock input. setting tr2 allows tl2 to be incremented by the selected input. timer 2 has 3 operating modes: capture, auto reload and baud rate generator. these modes are selected by the combination of rclk, tclk and cp/rl2 (t2con). refer to the atmel 8-bit microcontroller hardware documentation for the description of capture and baud rate generator modes. timer 2 includes the following enhancements: ? auto-reload mode with up or down counter ? programmable clock-output auto-reload mode the auto-reload mode configures timer 2 as a 16-bit timer or event counter with auto- matic reload. if dcen bit in t2mod is cleared, timer 2 behaves as in 80c52 (refer to the atmel 8-bit microcontroller hardware description). if dcen bit is set, timer 2 acts as an up/down timer/counter as shown in figure 25. in this mode the t2ex pin controls the direction of count. when t2ex is high, timer 2 counts up. timer overflow occurs at ffffh which sets the tf2 flag and generates an interrupt request. the overflow also causes the 16-bit value in rcap2h and rcap2l registers to be loaded into the timer registers th2 and tl2. when t2ex is low, timer 2 counts down. timer underflow occurs when the count in the timer registers th2 and tl2 equals the value stored in rcap2h and rcap2l registers. the underflow sets tf2 flag and reloads ffffh into the timer registers. the exf2 bit toggles when timer 2 overflows or underflows according to the direction of the count. exf2 does not generate any interrupt. this bit can be used to provide 17-bit resolution.
51 at89c5131a-l 4338e?usb?06/06 figure 25. auto-reload mode up/down counter (dcen = 1) programmable clock output in the clock-out mode, timer 2 operates as a 50%-duty-cycle, programmable clock gen- erator (see figure 26). the input clock increments tl2 at frequency f clk periph /2. the timer repeatedly counts to overflow from a loaded value. at overflow, the contents of rcap2h and rcap2l registers are loaded into th2 and tl2. in this mode, timer 2 overflows do not generate interrupts. the following formula gives the clock-out fre- quency as a function of the system oscillator frequency and the value in the rcap2h and rcap2l registers for a 16 mhz system clock, timer 2 has a programmable frequency range of 61 hz (f clk periph /2 16) to 4 mhz (f clk periph /4). the generated clock signal is brought out to t2 pin (p1.0). timer 2 is programmed for the clock-out mode as follows: ? set t2oe bit in t2mod register. ? clear c/t2 bit in t2con register. ? determine the 16-bit reload value from the formula and enter it in rcap2h/rcap2l registers. ? enter a 16-bit initial value in timer registers th2/tl2. it can be the same as the reload value or a different one depending on the application. ? to start the timer, set tr2 run control bit in t2con register. (down counting reload value) c/t 2 tf2 tr2 t2 exf2 th2 (8-bit) tl2 (8-bit) rcap2h (8-bit) rcap2l (8-bit) ffh (8-bit) ffh (8-bit) toggle (up counting reload value) timer 2 interrupt f clk periph 0 1 t2con t2con t2con t2con t2ex: if dcen = 1, 1 = up if dcen = 1, 0 = down if dcen = 0, up counting : 6 clock outfrequency C f clkperiph 4 65536 rcap 2 h C rcap 2 l ? () ---------------------------------------------------------------------------------------- - =
52 at89c5131a-l 4338e?usb?06/06 it is possible to use timer 2 as a baud rate generator and a clock generator simulta- neously. for this configuration, the baud rates and clock frequencies are not independent since both functions use the values in the rcap2h and rcap2l registers. figure 26. clock-out mode c/t2 = 0 : 6 exf2 tr2 overflow t2ex th2 (8-bit) tl2 (8-bit) timer 2 rcap2h (8-bit) rcap2l (8-bit) t2oe t2 f clk periph t2con t2con t2con t2mod interrupt qd toggle exen2
53 at89c5131a-l 4338e?usb?06/06 reset value = 0000 0000b bit addressable table 46. t2con register t2con - timer 2 control register (c8h) 76543210 tf2 exf2 rclk tclk exen2 tr2 c/t2# cp/rl2# bit number bit mnemonic description 7tf2 timer 2 overflow flag must be cleared by software. set by hardware on timer 2 overflow, if rclk = 0 and tclk = 0. 6 exf2 timer 2 external flag set when a capture or a reload is caused by a negative transition on t2ex pin if exen2 = 1. when set, causes the cpu to vector to timer 2 interrupt routine when timer 2 interrupt is enabled. must be cleared by software. exf2 doesn?t cause an interrupt in up/down counter mode (dcen = 1). 5 rclk receive clock bit cleared to use timer 1 overflow as receive clock for serial port in mode 1 or 3. set to use timer 2 overflow as receive clock for serial port in mode 1 or 3. 4tclk transmit clock bit cleared to use timer 1 overflow as transmit clock for serial port in mode 1 or 3. set to use timer 2 overflow as transmit clock for serial port in mode 1 or 3. 3 exen2 timer 2 external enable bit cleared to ignore events on t2ex pin for timer 2 operation. set to cause a capture or reload when a negative transition on t2ex pin is detected, if timer 2 is not used to clock the serial port. 2tr2 timer 2 run control bit cleared to turn off timer 2. set to turn on timer 2. 1c/t2# timer/counter 2 select bit cleared for timer operation (input from internal clock system: f clk periph ). set for counter operation (input from t2 input pin, falling edge trigger). must be 0 for clock out mode. 0cp/rl2# timer 2 capture/reload bit if rclk = 1 or tclk = 1, cp/rl2# is ignored and timer is forced to auto-reload on timer 2 overflow. cleared to auto-reload on timer 2 overflows or negative transitions on t2ex pin if exen2 = 1. set to capture on negative transitions on t2ex pin if exen2 = 1.
54 at89c5131a-l 4338e?usb?06/06 reset value = xxxx xx00b not bit addressable table 47. t2mod register t2mod - timer 2 mode control register (c9h) 76543210 ------t2oedcen bit number bit mnemonic description 7- reserved the value read from this bit is indeterminate. do not set this bit. 6- reserved the value read from this bit is indeterminate. do not set this bit. 5- reserved the value read from this bit is indeterminate. do not set this bit. 4- reserved the value read from this bit is indeterminate. do not set this bit. 3- reserved the value read from this bit is indeterminate. do not set this bit. 2- reserved the value read from this bit is indeterminate. do not set this bit. 1t2oe timer 2 output enable bit cleared to program p1.0/t2 as clock input or i/o port. set to program p1.0/t2 as clock output. 0 dcen down counter enable bit cleared to disable timer 2 as up/down counter. set to enable timer 2 as up/down counter.
55 at89c5131a-l 4338e?usb?06/06 programmable counter array (pca) the pca provides more timing capabilities with less cpu intervention than the standard timer/counters. its advantages include reduced software overhead and improved accu- racy. the pca consists of a dedicated timer/counter which serves as the time base for an array of five compare/capture modules. its clock input can be programmed to count any one of the following signals: ? peripheral clock frequency (f clk periph ) 6 ? peripheral clock frequency (f clk periph ) 2 ? timer 0 overflow ? external input on eci (p1.2) each compare/capture modules can be programmed in any one of the following modes: ? rising and/or falling edge capture, ? software timer ? high-speed output, or ? pulse width modulator module 4 can also be programmed as a watchdog timer (see section "pca watchdog timer", page 65). when the compare/capture modules are programmed in the capture mode, software timer, or high speed output mode, an interrupt can be generated when the module exe- cutes its function. all five modules plus the pca timer overflow share one interrupt vector. the pca timer/counter and compare/capture modules share port 1 for external i/o. these pins are listed below. if the port pin is not used for the pca, it can still be used for standard i/o. the pca timer is a common time base for all five modules (see figure 27). the timer count source is determined from the cps1 and cps0 bits in the cmod register (table 48) and can be programmed to run at: ? 1/6 the peripheral clock frequency (f clk periph ) . ? 1/2 the peripheral clock frequency (f clk periph ) . ? the timer 0 overflow ? the input on the eci pin (p1.2) pca component external i/o pin 16-bit counter p1.2/eci 16-bit module 0 p1.3/cex0 16-bit module 1 p1.4/cex1 16-bit module 2 p1.5/cex2 16-bit module 3 p1.6/cex3 16-bit module 4 p1.7/cex4
56 at89c5131a-l 4338e?usb?06/06 figure 27. pca timer/counter table 48. cmod register cmod - pca counter mode register (d9h) reset value = 00xx x000b not bit addressable cidl cps1 cps0 ecf it ch cl 16 bit up counter to pca modules f clk periph /6 f clk periph /2 t0 ovf p1.2 idle cmod 0xd9 wdte cf cr ccon 0xd8 ccf4 ccf3 ccf2 ccf1 ccf0 overflow 7 6 5 4 3 2 1 0 cidl wdte - - - cps1 cps0 ecf bit number bit mnemonic description 7cidl counter idle control cleared to program the pca counter to continue functioning during idle mode. set to program pca to be gated off during idle. 6wdte watchdog timer enable cleared to disable watchdog timer function on pca module 4. set to enable watchdog timer function on pca module 4. 5- reserved the value read from this bit is indeterminate. do not set this bit. 4- reserved the value read from this bit is indeterminate. do not set this bit. 3- reserved the value read from this bit is indeterminate. do not set this bit. 2cps1 pca count pulse select cps1 cps0 selected pca input 0 0 internal clock f clk periph /6 0 1 internal clock f clk periph /2 1 0 timer 0 overflow 1 1 external clock at eci/p1.2 pin (max rate = f clk periph / 4) 1cps0 0ecf pca enable counter overflow interrupt cleared to disable cf bit in ccon to inhibit an interrupt. set to enable cf bit in ccon to generate an interrupt.
57 at89c5131a-l 4338e?usb?06/06 the cmod register includes three additional bits associated with the pca (see figure 27 and table 48). ? the cidl bit allows the pca to stop during idle mode. ? the wdte bit enables or disables the watchdog function on module 4. ? the ecf bit when set causes an interrupt and the pca overflow flag cf (in the ccon sfr) to be set when the pca timer overflows. the ccon register contains the run control bit for the pca and the flags for the pca timer (cf) and each module (see table 49). ? bit cr (ccon.6) must be set by software to run the pca. the pca is shut off by clearing this bit. ? bit cf: the cf bit (ccon.7) is set when the pca counter overflows and an interrupt will be generated if the ecf bit in the cmod register is set. the cf bit can only be cleared by software. ? bits 0 through 4 are the flags for the modules (bit 0 for module 0, bit 1 for module 1, etc.) and are set by hardware when either a match or a capture occurs. these flags can only be cleared by software. reset value = 000x 0000b not bit addressable table 49. ccon register ccon - pca counter control register (d8h) 76543210 cf cr ? ccf4 ccf3 ccf2 ccf1 ccf0 bit number bit mnemonic description 7cf pca counter overflow flag set by hardware when the counter rolls over. cf flags an interrupt if bit ecf in cmod is set. cf may be set by either hardware or software but can only be cleared by software. 6cr pca counter run control bit must be cleared by software to turn the pca counter off. set by software to turn the pca counter on. 5? reserved the value read from this bit is indeterminate. do not set this bit. 4 ccf4 pca module 4 interrupt flag must be cleared by software. set by hardware when a match or capture occurs. 3 ccf3 pca module 3 interrupt flag must be cleared by software. set by hardware when a match or capture occurs. 2 ccf2 pca module 2 interrupt flag must be cleared by software. set by hardware when a match or capture occurs. 1 ccf1 pca module 1 interrupt flag must be cleared by software. set by hardware when a match or capture occurs. 0 ccf0 pca module 0 interrupt flag must be cleared by software. set by hardware when a match or capture occurs.
58 at89c5131a-l 4338e?usb?06/06 the watchdog timer function is implemented in module 4 (see figure 30). the pca interrupt system is shown in figure 28. figure 28. pca interrupt system pca modules: each one of the five compare/capture modules has six possible func- tions. it can perform: ? 16-bit capture, positive-edge triggered ? 16-bit capture, negative-edge triggered ? 16-bit capture, both positive and negative-edge triggered ? 16-bit software timer ? 16-bit high-speed output ? 8-bit pulse width modulator in addition, module 4 can be used as a watchdog timer. each module in the pca has a special function register associated with it. these regis- ters are: ccapm0 for module 0, ccapm1 for module 1, etc. (see table 50). the registers contain the bits that control the mode that each module will operate in. ? the eccf bit (ccapmn.0 where n = 0, 1, 2, 3, or 4 depending on the module) enables the ccf flag in the ccon sfr to generate an interrupt when a match or compare occurs in the associated module. ? pwm (ccapmn.1) enables the pulse width modulation mode. ? the tog bit (ccapmn.2) when set causes the cex output associated with the module to toggle when there is a match between the pca counter and the module's capture/compare register. ? the match bit mat (ccapmn.3) when set will cause the ccfn bit in the ccon register to be set when there is a match between the pca counter and the module's capture/compare register. ? the next two bits capn (ccapmn.4) and capp (ccapmn.5) determine the edge that a capture input will be active on. the capn bit enables the negative edge, and cf cr ccon 0xd8 ccf4 ccf3 ccf2 ccf1 ccf0 module 4 module 3 module 2 module 1 module 0 ecf pca timer/counter eccfn ccapmn.0 cmod.0 ie.6 ie.7 to interrupt priority decoder ec ea
59 at89c5131a-l 4338e?usb?06/06 the capp bit enables the positive edge. if both bits are set both edges will be enabled and a captur e will occur for either transition. ? the last bit in the register ecom (cc apmn.6) when set enables the comparator function. table 51 shows the ccapmn settings for the various pca functions. table 50. ccapmn registers (n = 0-4) ccapm0 - pca module 0 compare/capture control register (0dah) ccapm1 - pca module 1 compare/capture control register (0dbh) ccapm2 - pca module 2 compare/capture control register (0dch) ccapm3 - pca module 3 compare/capture control register (0ddh) ccapm4 - pca module 4 compare/capture control register (0deh) reset value = x000 0000b not bit addressable 7 6 5 4 3 2 1 0 - ecomn cappn capnn matn togn pwmn eccfn bit number bit mnemonic description 7- reserved the value read from this bit is indeterminate. do not set this bit. 6ecomn enable comparator cleared to disable the comparator function. set to enable the comparator function. 5 cappn capture positive cleared to disable positive edge capture. set to enable positive edge capture. 4capnn capture negative cleared to disable negative edge capture. set to enable negative edge capture. 3matn match when matn = 1, a match of the pca counter with this module's compare/capture register causes the ccfn bit in ccon to be set, flagging an interrupt. 2 togn to gg le when togn = 1, a match of the pca counter with this module's compare/capture register causes the cexn pin to toggle. 1pwmn pulse width modulation mode cleared to disable the cexn pin to be used as a pulse width modulated output. set to enable the cexn pin to be used as a pulse width modulated output. 0 eccfn enable ccf interrupt cleared to disable compare/capture flag ccfn in the ccon register to generate an interrupt. set to enable compare/capture flag ccfn in the ccon register to generate an interrupt.
60 at89c5131a-l 4338e?usb?06/06 table 51. pca module modes (ccapmn registers) there are two additional registers associated with each of the pca modules. they are ccapnh and ccapnl and these are the registers that store the 16-bit count when a capture occurs or a compare should occur. when a module is used in the pwm mode these registers are used to control the duty cycle of the output (see table 52 and table 53) ecomn cappn capnn matn togn pwm m eccf n module function 0 0 0 0 0 0 0 no operation x1 0000x 16-bit capture by a positive- edge trigger on cexn x0 1000x 16-bit capture by a negative trigger on cexn x1 1000x 16-bit capture by a transition on cexn 10 0100x 16-bit software timer/compare mode. 1 0 0 1 1 0 x 16-bit high speed output 10 000108-bit pwm 10 01x0x watchdog timer (module 4 only)
61 at89c5131a-l 4338e?usb?06/06 table 52. ccapnh registers (n = 0-4) ccap0h - pca module 0 compare/capture control register high (0fah) ccap1h - pca module 1 compare/capture control register high (0fbh) ccap2h - pca module 2 compare/capture control register high (0fch) ccap3h - pca module 3 compare/capture control register high (0fdh) ccap4h - pca module 4 compare/capture control register high (0feh) reset value = xxxx xxxxb not bit addressable table 53. ccapnl registers (n = 0-4) ccap0l - pca module 0 compare/capture control register low (0eah) ccap1l - pca module 1 compare/capture control register low (0ebh) ccap2l - pca module 2 compare/capture control register low (0ech) ccap3l - pca module 3 compare/capture control register low (0edh) ccap4l - pca module 4 compare/capture control register low (0eeh) reset value = xxxx xxxxb not bit addressable table 54. ch register ch - pca counter register high (0f9h) reset value = 0000 0000b not bit addressable 76543210 -------- bit number bit mnemonic description 7 - 0 - pca module n compare/capture control ccapnh value 7 6 5 4 3 2 1 0 - - - - - - - - bit number bit mnemonic description 7 - 0 - pca module n compare/capture control ccapnl value 7 6 5 4 3 2 1 0 - - - - - - - - bit number bit mnemonic description 7 - 0 - pca counter ch value
62 at89c5131a-l 4338e?usb?06/06 table 55. cl register cl - pca counter register low (0e9h) reset value = 0000 0000b not bit addressable pca capture mode to use one of the pca modules in the capture mode either one or both of the ccapm bits capn and capp for that module must be set. the external cex input for the mod- ule (on port 1) is sampled for a transition. when a valid transition occurs the pca hardware loads the value of the pca counter registers (ch and cl) into the module's capture registers (ccapnl and ccapnh). if the ccfn bit for the module in the ccon sfr and the eccfn bit in the ccapmn sfr are set then an interrupt will be generated (see figure 29). figure 29. pca capture mode 16-bit software timer/compare mode the pca modules can be used as software timers by setting both the ecom and mat bits in the modules ccapmn register. the pca timer will be compared to the module's capture registers and when a match occurs an interrupt will occur if the ccfn (ccon sfr) and the eccfn (ccapmn sfr) bits for the module are both set (see figure 30). 7 6 5 4 3 2 1 0 - - - - - - - - bit number bit mnemonic description 7 - 0 - pca counter cl value cf cr ccon 0xd8 ch cl ccapnh ccapnl ccf4 ccf3 ccf2 ccf1 ccf0 pca it pca counter/timer ecomn ccapmn, n = 0 to 4 0xda to 0xde capnn matn togn pwmn eccfn cappn cex.n capture
63 at89c5131a-l 4338e?usb?06/06 figure 30. pca compare mode and pca watchdog timer note: 1. only for module 4 before enabling ecom bit, ccapnl and ccapnh should be set with a non zero value, otherwise an unwanted match could happen. writing to ccapnh will set the ecom bit. once ecom set, writing ccapnl will clear ecom so that an unwanted match doesn?t occur while modifying the compare value. writing to ccapnh will set ecom. for this reason, user software should write ccapnl first, and then ccapnh. of course, the ecom bit can still be controlled by accessing to ccapmn register. high speed output mode in this mode, the cex output (on port 1) associated with the pc a module will toggle each time a match occurs between the pca counter and the module's capture registers. to activate this mode the tog, mat, and ecom bits in the module's ccapmn sfr must be set (see figure 31). a prior write must be done to ccapnl and ccapnh before writing the ecomn bit. ch cl ccapnh ccapnl ecomn ccapmn, n = 0 to 4 0xda to 0xde capnn matn togn pwmn eccfn cappn 16-bit comparator match ccon 0xd8 pca it enable pca counter/timer reset (1) cidl cps1 cps0 ecf cmod 0xd9 wdte reset write to ccapnl write to ccapnh cf ccf2 ccf1 ccf0 cr ccf3 ccf4 10
64 at89c5131a-l 4338e?usb?06/06 figure 31. pca high-speed output mode before enabling ecom bit, ccapnl and ccapnh should be set with a non zero value, otherwise an unwanted match could happen. once ecom set, writing ccapnl will clear ecom so that an unwanted match doesn?t occur while modifying the compare value. writing to ccapnh will set ecom. for this reason, user software should write ccapnl first, and then ccapnh. of course, the ecom bit can still be controlled by accessing to ccapmn register. pulse width modulator mode all of the pca modules can be used as pwm outputs. figure 32 shows the pwm func- tion. the frequency of the output depends on the source for the pca timer. all of the modules will have the same frequency of output because they all share the pca timer. the duty cycle of each module is independently variable using the module's capture register ccapln. when the value of the pca cl sfr is less than the value in the mod- ule's ccapln sfr the output will be low, when it is equal to or greater than the output will be high. when cl overflows from ff to 00, ccapln is reloaded with the value in ccaphn. this allows updating the pwm without glitches. the pwm and ecom bits in the module's ccapmn register must be set to enable the pwm mode. ch cl ccapnh ccapnl ecomn ccapmn, n = 0 to 4 0xda to 0xde capnn matn togn pwmn eccfn cappn 16-bit comparator match cf cr ccon 0xd8 ccf4 ccf3 ccf2 ccf1 ccf0 pca it enable cexn pca counter/timer write to ccapnh reset write to ccapnl 1 0
65 at89c5131a-l 4338e?usb?06/06 figure 32. pca pwm mode pca watchdog timer an on-board watchdog timer is available with the pca to improve the reliability of the system without increasing chip count. watchdog timers are useful for systems that are susceptible to noise, power glitches, or electrostatic discharge. module 4 is the only pca module that can be programmed as a watchdog. however, this module can still be used for other modes if the watchdog is not needed. figure 30 shows a diagram of how the watchdog works. the user pre-loads a 16-bit value in the compare registers. just like the other compare modes, this 16-bit value is compared to the pca timer value. if a match is allowed to occur, an internal reset will be generated. this will not cause the rst pin to be driven low. in order to hold off the reset, the user has three options: 1. periodically change the compare value so it will never match the pca timer 2. periodically change the pca timer value so it will never match the compare val- ues, or 3. disable the watchdog by clearing the wdte bit before a match occurs and then re-enable it the first two options are more reliable because the watchdog timer is never disabled as in option #3. if the program counter ever goes astray, a match will eventually occur and cause an internal reset. the second option is also not recommended if other pca mod- ules are being used. remember, the pca timer is the time base for all modules; changing the time base for other modules would not be a good idea. thus, in most appli- cations the first solution is the best option. this watchdog timer won?t generate a reset out on the reset pin. cl ccapnh ccapnl ecomn ccapmn, n = 0 to 4 0xda to 0xde capnn matn togn pwmn eccfn cappn 8-bit comparator cexn ?0? ?1? < enable pca counter/timer overflow
66 at89c5131a-l 4338e?usb?06/06 serial i/o port the serial i/o port in the at89c5131a-l is compatible with the serial i/o port in the 80c52. it provides both synchronous and asynchronous communication modes. it operates as an universal asynchronous receiver and transmitter (uart) in three full-duplex modes (modes 1, 2 and 3). asynchronous transmission and reception can occur simul- taneously and at different baud rates. serial i/o port includes the following enhancements: ? framing error detection ? automatic address recognition framing error detection framing bit error detection is provided for the three asynchronous modes (modes 1, 2 and 3). to enable the framing bit error detection feature, set smod0 bit in pcon regis- ter (see figure 33). figure 33. framing error block diagram when this feature is enabled, the receiver checks each incoming data frame for a valid stop bit. an invalid stop bit may result from noise on the serial lines or from simultaneous transmission by two cpus. if a valid stop bit is not found, the framing error bit (fe) in scon register (see table 56) bit is set. software may examine fe bit after each reception to check for data errors. once set, only software or a reset can clear fe bit. subsequently received frames with valid stop bits cannot clear fe bit. when fe feature is enabled, ri rises on stop bit instead of the last data bit (see figure 34 and figure 35). figure 34. uart timings in mode 1 ri ti rb8 tb8 ren sm2 sm1 sm0/fe idl pd gf0 gf1 pof - smod0 smod1 to uart framing error control sm0 to uart mode control (smod0 = 0) set fe bit if stop bit is 0 (framing error) (smod0 = 1 scon (98 h) pcon (87 h) data byte ri smod0 = x stop bit start bit rxd d7 d6 d5 d4 d3 d2 d1 d0 fe smod0 = 1
67 at89c5131a-l 4338e?usb?06/06 figure 35. uart timings in modes 2 and 3 automatic address recognition the automatic address recognition feature is enabled when the multiprocessor commu- nication feature is enabled (sm2 bit in scon register is set). implemented in hardware, automatic address recognition enhances the multiprocessor communication feature by allowing the serial port to examine the address of each incoming command frame. only when the serial port recognizes its own address, the receiver sets ri bit in scon register to generate an interrupt. this ensures that the cpu is not interrupted by command frames addressed to other devices. if desired, you may enable the automatic address recognition feature in mode 1. in this configuration, the stop bit takes the place of the ninth data bit. bit ri is set only when the received command frame address matches the device?s address and is terminated by a valid stop bit. to support automatic address recognition, a device is identified by a given address and a broadcast address. note: the multiprocessor communication and automatic address recognition features cannot be enabled in mode 0 (i.e., setting sm2 bit in scon register in mode 0 has no effect). given address each device has an individual address that is specified in saddr register; the saden register is a mask byte that contains don?t care bits (defined by zeros) to form the device?s given address. the don?t care bits provide the flexibility to address one or more slaves at a time. the following example illustrates how a giv en address is formed. to address a device by its individual address, the saden mask byte must be 1111 1111b . for example: saddr0101 0110b saden 1111 1100b given0101 01xxb the following is an example of how to use given addresses to address different slaves: slave a:saddr1111 0001b saden 1111 1010b given1111 0x0xb slave b:saddr1111 0011b saden 1111 1001b given1111 0x x1b slave c:saddr1111 0011b saden 1111 1101b given1111 00x1b ri smod0 = 0 data byte ninth bit stop bit start bit rxd d8 d7 d6 d5 d4 d3 d2 d1 d0 ri smod0 = 1 fe smod0 = 1
68 at89c5131a-l 4338e?usb?06/06 the saden byte is selected so that each slave may be addressed separately. for slave a, bit 0 (the lsb) is a don?t care bit; for slaves b and c, bit 0 is a 1. to commu- nicate with slave a only, the master must send an address where bit 0 is clear (e.g. 1111 0000b ). for slave a, bit 1 is a 1; for slaves b and c, bit 1 is a don?t care bit. to communicate with slaves b and c, but not slave a, the master must send an address with bits 0 and 1 both set (e.g. 1111 0011b ). to communicate with slaves a, b and c, the master must send an address with bit 0 set, bit 1 clear, and bit 2 clear (e.g. 1111 0001b ). broadcast address a broadcast address is formed from the logical or of the saddr and saden registers with zeros defined as don?t care bits, e.g.: saddr0101 0110b sade n1111 1100b broadcast = saddr or saden1111 111xb the use of don?t care bits provides flexibility in defining the broadcast address, in most applications, a broadcast address is ffh. the following is an example of using broad- cast addresses: slave a:saddr1111 0001b saden 1111 1010b broadcast1111 1x 11b, slave b:saddr1111 0011b saden 1111 1001b broadcast1111 1x 11b, slave c:saddr = 1111 0011b saden 1111 1101b broadcast1111 1111b for slaves a and b, bit 2 is a don?t care bit; for slave c, bit 2 is set. to communicate with all of the slaves, the master must send an address ffh. to communicate with slaves a and b, but not slave c, the master can send and address fbh. reset addresses on reset, the saddr and saden registers are initialized to 00h, i.e. the given and broadcast addresses are xxxx xxxxb (all don?t care bits). this ensures that the serial port will reply to any address, and so, that it is backwards compatible with the 80c51 microcontrollers that do not support automatic address recognition. saden - slave address mask register (b9h) reset value = 0000 0000b not bit addressable 7 6 5 4 3 2 1 0
69 at89c5131a-l 4338e?usb?06/06 saddr - slave address register (a9h) reset value = 0000 0000b not bit addressable baud rate selection for uart for mode 1 and 3 the baud rate generator for transmit and re ceive clocks can be selected separately via the t2con and bdrcon registers. figure 36. baud rate selection baud rate selection table for uart internal baud rate generator (brg) when the internal baud rate generator is used, the baud rates are determined by the brg overflow depending on the brl reload value, the value of spd bit (speed mode) in bdrcon register and the value of the smod1 bit in pcon register. 7 6 5 4 3 2 1 0 rclk / 16 rbck int_brg 0 1 timer1 0 1 0 1 timer2 int_brg timer1 timer2 timer_brg_rx rx clock / 16 0 1 timer_brg_tx tx clock tbck tclk tclk (t2con) rclk (t2con) tbck (bdrcon) rbck (bdrcon) clock source uart tx clock source uart rx 0000timer 1timer 1 1000timer 2timer 1 0100timer 1timer 2 1100timer 2timer 2 x010int_brgtimer 1 x110int_brgtimer 2 0 x 0 1 timer 1 int_brg 1 x 0 1 timer 2 int_brg x x 1 1 int_brg int_brg
70 at89c5131a-l 4338e?usb?06/06 figure 37. internal baud rate ? the baud rate for uart is token by formula: brg 0 1 /6 brl /2 0 1 int_brg spd brr smod1 auto reload counter overflow peripheral clock baud_rate = 2 smod1 x f clk periph 2 x 6 (1-spd) x 16 x [256 - (brl)] (brl) = 256 - 2 smod1 x f clk periph 2 x 6 (1-spd) x 16 x baud_rate
71 at89c5131a-l 4338e?usb?06/06 table 56. scon register ? scon seri al control register (98h) reset value = 0000 0000b bit addressable 76543210 fe/sm0 sm1 sm2 ren tb8 rb8 ti ri bit number bit mnemonic description 7 fe framing error bit (smod0 = 1 ) clear to reset the error state, not cleared by a valid stop bit. set by hardware when an invalid stop bit is detected. smod0 must be set to enable access to the fe bit sm0 serial port mode bit 0 refer to sm1 for serial port mode selection. smod0 must be cleared to enable access to the sm0 bit 6sm1 serial port mode bit 1 sm0 sm1 mode description baud rate 0 0 0 shift registerf cpu periph /6 0 1 1 8-bit uartvariable 1 0 2 9-bit uartf cpu periph/ 32 or/16 1 1 3 9-bit uart variable 5sm2 serial port mode 2 bit/multiprocessor communication enable bit clear to disable multiprocessor communication feature. set to enable multiprocessor communication feature in mode 2 and 3, and eventually mode 1. this bit should be cleared in mode 0. 4ren reception enable bit clear to disable serial reception. set to enable serial reception. 3tb8 transmitter bit 8/ninth bit to transmit in modes 2 and 3 clear to transmit a logic 0 in the 9th bit. set to transmit a logic 1 in the 9th bit. 2rb8 receiver bit 8/ninth bit received in modes 2 and 3 cleared by hardware if 9th bit received is a logic 0. set by hardware if 9th bit received is a logic 1. in mode 1, if sm2 = 0, rb8 is the received stop bit. in mode 0 rb8 is not used. 1ti transmit interrupt flag clear to acknowledge interrupt. set by hardware at the end of the 8th bit time in mode 0 or at the beginning of the stop bit in the other modes. 0ri receive interrupt flag clear to acknowledge interrupt. set by hardware at the end of the 8th bit time in mode 0, see figure 34. and figure 35. in the other modes.
72 at89c5131a-l 4338e?usb?06/06 example of computed value when x2 = 1, smod1 = 1, spd = 1 example of computed value when x2 = 0, smod1 = 0, spd = 0 the baud rate generator can be used for mode 1 or 3 (refer to figure 36.), but also for mode 0 for uart, thanks to the bit src located in bdrcon register (table 59.) uart registers saden - slave address mask register for uart (b9h) reset value = 0000 0000b saddr - slave address register for uart (a9h) reset value = 0000 0000b sbuf - serial buffer register for uart (99h) reset value = xxxx xxxxb baud rates f osc = 16.384 mhz f osc = 24 mhz brl error (%) brl error (%) 115200 247 1.23 243 0.16 57600 238 1.23 230 0.16 38400 229 1.23 217 0.16 28800 220 1.23 204 0.16 19200 203 0.63 178 0.16 9600 149 0.31 100 0.16 4800 43 1.23 - - baud rates f osc = 16.384 mhz f osc = 24 mhz brl error (%) brl error (%) 4800 247 1.23 243 0.16 2400 238 1.23 230 0.16 1200 220 1.23 202 3.55 600 185 0.16 152 0.16 7 6 5 4 3 2 1 0 ? ? ? ? ? ? ? ? 7 6 5 4 3 2 1 0 ? ? ? ? ? ? ? ? 7 6 5 4 3 2 1 0 ? ? ? ? ? ? ? ?
73 at89c5131a-l 4338e?usb?06/06 brl - baud rate reload register for the internal baud rate generator, uart (9ah) reset value = 0000 0000b table 57. t2con register t2con - timer 2 control register (c8h) reset value = 0000 0000b bit addressable 7 6 5 4 3 2 1 0 ? ? ? ? ? ? ? ? 7 6 5 4 3 2 1 0 tf2 exf2 rclk tclk exen2 tr2 c/t2# cp/rl2# bit number bit mnemonic description 7tf2 timer 2 overflow flag must be cleared by software. set by hardware on timer 2 overflow, if rclk = 0 and tclk = 0. 6 exf2 timer 2 external flag set when a capture or a reload is caused by a negative transition on t2ex pin if exen2 = 1. when set, causes the cpu to vector to timer 2 interrupt routine when timer 2 interrupt is enabled. must be cleared by software. exf2 doesn?t cause an interrupt in up/down counter mode (dcen = 1) 5 rclk receive clock bit for uart cleared to use timer 1 overflow as receive clock for serial port in mode 1 or 3. set to use timer 2 overflow as receive clock for serial port in mode 1 or 3. 4tclk transmit clock bit for uart cleared to use timer 1 overflow as transmit clock for serial port in mode 1 or 3. set to use timer 2 overflow as transmit clock for serial port in mode 1 or 3. 3 exen2 timer 2 external enable bit cleared to ignore events on t2ex pin for timer 2 operation. set to cause a capture or reload when a negative transition on t2ex pin is detected, if timer 2 is not used to clock the serial port. 2tr2 timer 2 run control bit cleared to turn off timer 2. set to turn on timer 2. 1c/t2# timer/counter 2 select bit cleared for timer operation (input from internal clock system: f clk periph ). set for counter operation (input from t2 input pin, falling edge trigger). must be 0 for clock out mode. 0cp/rl2# timer 2 capture/reload bit if rclk = 1 or tclk = 1, cp/rl2# is ignored and timer is forced to auto-reload on timer 2 overflow. cleared to auto-reload on timer 2 overflows or negative transitions on t2ex pin if exen2 = 1. set to capture on negative transitions on t2ex pin if exen2 = 1.
74 at89c5131a-l 4338e?usb?06/06 table 58. pcon register pcon - power control register (87h) reset value = 00x1 0000b not bit addressable power-off flag reset value will be 1 only after a power on (cold reset). a warm reset doesn?t affect the value of this bit. 7 6 5 4 3 2 1 0 smod1 smod0 - pof gf1 gf0 pd idl bit number bit mnemonic description 7smod1 serial port mode bit 1 for uart set to select double baud rate in mode 1, 2 or 3. 6smod0 serial port mode bit 0 for uart cleared to select sm0 bit in scon register. set to select fe bit in scon register. 5- reserved the value read from this bit is indeterminate. do not set this bit. 4pof power-off flag cleared to recognize next reset type. set by hardware when v cc rises from 0 to its nominal voltage. can also be set by software. 3gf1 general-purpose flag cleared by user for general-purpose usage. set by user for general-purpose usage. 2gf0 general-purpose flag cleared by user for general-purpose usage. set by user for general-purpose usage. 1pd power-down mode bit cleared by hardware when reset occurs. set to enter power-down mode. 0idl idle mode bit cleared by hardware when interrupt or reset occurs. set to enter idle mode.
75 at89c5131a-l 4338e?usb?06/06 table 59. bdrcon register bdrcon - baud rate control register (9bh) reset value = xxx0 0000b not bit addressable 7 6 5 4 3 2 1 0 - - - brr tbck rbck spd src bit number bit mnemonic description 7- reserved the value read from this bit is indeterminate. do not set this bit 6- reserved the value read from this bit is indeterminate. do not set this bit 5- reserved the value read from this bit is indeterminate. do not set this bit. 4brr baud rate run control bit cleared to stop the internal baud rate generator. set to start the internal baud rate generator. 3tbck transmission baud rate generator selection bit for uart cleared to select timer 1 or timer 2 for the baud rate generator. set to select internal baud rate generator. 2rbck reception baud rate generator selection bit for uart cleared to select timer 1 or timer 2 for the baud rate generator. set to select internal baud rate generator. 1spd baud rate speed control bit for uart cleared to select the slow baud rate generator. set to select the fast baud rate generator. 0src baud rate source select bit in mode 0 for uart cleared to select f osc /12 as the baud rate generator (f clk periph /6 in x2 mode). set to select the internal baud rate generator for uarts in mode 0.
76 at89c5131a-l 4338e?usb?06/06 interrupt system overview the at89c5131a-l has a total of 11 interrupt vectors: two external interrupts (int0 and int1 ), three timer interrupts (timers 0, 1 and 2), the serial port interrupt, spi interrupt, keyboard interrupt, usb interrupt and the pca global interrupt. these interrupts are shown in figure 38. figure 38. interrupt control system ie1 0 3 high priority interrupt interrupt polling sequence, decreasing from high-to-low priority low priority interrupt global disable individual enable exf2 tf2 ti ri tf0 int0 int1 tf1 iph, ipl ie0 0 3 0 3 0 3 0 3 0 3 0 3 pca it kbd it spi it 0 3 0 3 0 3 uepint usbint 0 3 twi it 1 1 0 0 it0 tcon.0 it1 tcon.2
77 at89c5131a-l 4338e?usb?06/06 each of the interrupt sources can be individually enabled or disabled by setting or clear- ing a bit in the interrupt enable register (table 61). this register also contains a global disable bit, which must be cleared to disable all interrupts at once. each interrupt source can also be individually programmed to one out of four priority lev- els by setting or clearing a bit in the interrupt priority register (table 62.) and in the interrupt priority high register (table 63). table 60. shows the bit values and priority lev- els associated with each combination. registers the pca interrupt vector is located at address 0033h, the spi interrupt vector is located at address 004bh and keyboard interrupt vector is located at address 003bh. all other vectors addresses are the same as standard c52 devices. table 60. priority level bit values a low-priority interrupt can be interrupted by a high priority interrupt, but not by another low-priority interrupt. a high-priority interrupt can?t be interrupted by any other interrupt source. if two interrupt requests of different priority levels are received simultaneously, the request of higher priority level is serviced. if interrupt requests of the same priority level are received simultaneously, an internal polling sequence determines which request is serviced. thus within each priority level there is a second priority structure determined by the polling sequence. iph.x ipl.x interrupt level priority 0 0 0 (lowest) 011 102 113 (highest)
78 at89c5131a-l 4338e?usb?06/06 table 61. ien0 register ien0 - interrupt enable register (a8h) reset value = 0000 0000b bit addressable 7 6 5 4 3 2 1 0 ea ec et2 es et1 ex1 et0 ex0 bit number bit mnemonic description 7ea enable all interrupt bit cleared to disable all interrupts. set to enable all interrupts. 6ec pca interrupt enable bit cleared to disable. set to enable. 5et2 timer 2 overflow interrupt enable bit cleared to disable timer 2 overflow interrupt. set to enable timer 2 overflow interrupt. 4es serial port enable bit cleared to disable serial port interrupt. set to enable serial port interrupt. 3et1 timer 1 overflow interrupt enable bit cleared to disable timer 1 overflow interrupt. set to enable timer 1 overflow interrupt. 2ex1 external interrupt 1 enable bit cleared to disable external interrupt 1. set to enable external interrupt 1. 1et0 timer 0 overflow interrupt enable bit cleared to disable timer 0 overflow interrupt. set to enable timer 0 overflow interrupt. 0ex0 external interrupt 0 enable bit cleared to disable external interrupt 0. set to enable external interrupt 0.
79 at89c5131a-l 4338e?usb?06/06 table 62. ipl0 register ipl0 - interrupt priority register (b8h) reset value = x000 0000b bit addressable 7 6 5 4 3 2 1 0 - ppcl pt2l psl pt1l px1l pt0l px0l bit number bit mnemonic description 7- reserved the value read from this bit is indeterminate. do not set this bit. 6ppcl pca interrupt priority bit refer to ppch for priority level. 5pt2l timer 2 overflow interrupt priority bit refer to pt2h for priority level. 4psl serial port priority bit refer to psh for priority level. 3pt1l timer 1 overflow interrupt priority bit refer to pt1h for priority level. 2px1l external interrupt 1 priority bit refer to px1h for priority level. 1pt0l timer 0 overflow interrupt priority bit refer to pt0h for priority level. 0px0l external interrupt 0 priority bit refer to px0h for priority level.
80 at89c5131a-l 4338e?usb?06/06 table 63. iph0 register iph0 - interrupt priority high register (b7h) reset value = x000 0000b not bit addressable 7 6 5 4 3 2 1 0 - ppch pt2h psh pt1h px1h pt0h px0h bit number bit mnemonic description 7- reserved the value read from this bit is indeterminate. do not set this bit. 6 ppch pca interrupt priority high bit. ppch ppcl priority level 00lowest 01 10 1 1highest 5pt2h timer 2 overflow interrupt priority high bit pt2h pt2l priority level 00lowest 01 10 1 1highest 4 psh serial port priority high bit psh psl priority level 00lowest 01 10 1 1highest 3pt1h timer 1 overflow interrupt priority high bit pt1h pt1l priority level 00lowest 01 10 1 1highest 2px1h external interrupt 1 priority high bit px1h px1l priority level 00lowest 01 10 1 1highest 1pt0h timer 0 overflow interrupt priority high bit pt0h pt0l priority level 00lowest 01 10 1 1highest 0px0h external interrupt 0 priority high bit px0h px0l priority level 00lowest 01 10 1 1highest
81 at89c5131a-l 4338e?usb?06/06 table 64. ien1 register ien1 - interrupt enable register (b1h) reset value = x0xx x000b not bit addressable 7 6 5 4 3 2 1 0 - eusb - - - espi etwi ekb bit number bit mnemonic description 7-reserved 6eusb usb interrupt enable bit cleared to disable usb interrupt. set to enable usb interrupt. 5-reserved 4-reserved 3-reserved 2 espi spi interrupt enable bit cleared to disable spi interrupt. set to enable spi interrupt. 1etwi twi interrupt enable bit cleared to disable twi interrupt. set to enable twi interrupt. 0ekb keyboard interrupt enable bit cleared to disable keyboard interrupt. set to enable keyboard interrupt.
82 at89c5131a-l 4338e?usb?06/06 table 65. ipl1 register ipl1 - interrupt priority register (b2h) reset value = x0xx x000b not bit addressable 7 6 5 4 3 2 1 0 - pusbl - - - pspil ptwil pkbdl bit number bit mnemonic description 7- reserved the value read from this bit is indeterminate. do not set this bit. 6pusbl usb interrupt priority bit refer to pusbh for priority level. 5- reserved the value read from this bit is indeterminate. do not set this bit. 4- reserved the value read from this bit is indeterminate. do not set this bit. 3- reserved the value read from this bit is indeterminate. do not set this bit. 2 pspil spi interrupt priority bit refer to pspih for priority level. 1ptwil twi interrupt priority bit refer to ptwih for priority level. 0pkbl keyboard interrupt priority bit refer to pkbh for priority level.
83 at89c5131a-l 4338e?usb?06/06 table 66. iph1 register iph1 - interrupt priority high register (b3h) reset value = x0xx x000b not bit addressable 7 6 5 4 3 2 1 0 - pusbh - - - pspih ptwih pkbh bit number bit mnemonic description 7- reserved the value read from this bit is indeterminate. do not set this bit. 6 pusbh usb interrupt priority high bit pusbh pusbl priority level 00lowest 01 10 1 1highest 5- reserved the value read from this bit is indeterminate. do not set this bit. 4- reserved the value read from this bit is indeterminate. do not set this bit. 3- reserved the value read from this bit is indeterminate. do not set this bit. 2 pspih spi interrupt priority high bit pspih pspil priority level 00lowest 01 10 1 1highest 1ptwih twi interrupt priority high bit ptwih ptwil priority level 00lowest 01 10 1 1highest 0 pkbh keyboard interrupt priority high bit pkbh pkbl priority level 00lowest 01 10 1 1highest
84 at89c5131a-l 4338e?usb?06/06 interrupt sources and vector addresses table 67. vector table number polling priority interrupt source interrupt request vector address 0 0 reset 0000h 1 1 int0 ie0 0003h 2 2 timer 0 tf0 000bh 3 3 int1 ie1 0013h 4 4 timer 1 if1 001bh 5 6 uart ri+ti 0023h 6 7 timer 2 tf2+exf2 002bh 7 5 pca cf + ccfn (n = 0-4) 0033h 8 8 keyboard kbdit 003bh 9 9 twi twiit 0043h 10 10 spi spiit 004bh 11 11 0053h 12 12 005bh 13 13 0063h 14 14 usb uepint + usbint 006bh 15 15 0073h
85 at89c5131a-l 4338e?usb?06/06 keyboard interface introduction the at89c5131a-l implements a keyboard interface allowing the connection of a 8 x n matrix keyboard. it is based on 8 inputs with programmable interrupt capability on both high or low level. these inputs are available as an alternate function of p1 and allow to exit from idle and power down modes. description the keyboard interface communicates with the c51 core through 3 special function reg- isters: kbls, the keyboard level selection register (table 70), kbe, the keyboard interrupt enable register (table 69), and kbf, the keyboard flag register (table 68). interrupt the keyboard inputs are considered as 8 independent interrupt sources sharing the same interrupt vector. an interrupt enable bit (kbd in ie1) allows global enable or dis- able of the keyboard interrupt (see figure 39). as detailed in figure 40 each keyboard input has the capability to detect a programmable level according to kbls.x bit value. level detection is then reported in interrupt flags kbf.x that can be masked by software using kbe.x bits. this structure allow keyboard arrangement from 1 by n to 8 by n matrix and allow usage of p1 inputs for other purpose. figure 39. keyboard interface block diagram figure 40. keyboard input circuitry p1.0 keyboard interfac e interrupt request kbd ie1.0 input circuitry p1.1 input circuitry p1.2 input circuitry p1.3 input circuitry p1.4 input circuitry p1.5 input circuitry p1.6 input circuitry p1.7 input circuitry kbdit p1:x kbe.x kbf.x kbls.x 0 1 vcc internal pull-up
86 at89c5131a-l 4338e?usb?06/06 power reduction mode p1 inputs allow exit from idle and power down modes as detailed in section ?power- down mode?. registers table 68. kbf register kbf - keyboard flag register (9eh) reset value = 0000 0000b 76543210 kbf7 kbf6 kbf5 kbf4 kbf3 kbf2 kbf1 kbf0 bit number bit mnemonic description 7kbf7 keyboard line 7 flag set by hardware when the port line 7 detects a programmed level. it generates a keyboard interrupt request if the kbkbie.7 bit in kbie register is set. cleared by hardware when reading kbf sfr by software. 6kbf6 keyboard line 6 flag set by hardware when the port line 6 detects a programmed level. it generates a keyboard interrupt request if the kbie.6 bit in kbie register is set. cleared by hardware when reading kbf sfr by software. 5kbf5 keyboard line 5 flag set by hardware when the port line 5 detects a programmed level. it generates a keyboard interrupt request if the kbie.5 bit in kbie register is set. cleared by hardware when reading kbf sfr by software. 4kbf4 keyboard line 4 flag set by hardware when the port line 4 detects a programmed level. it generates a keyboard interrupt request if the kbie.4 bit in kbie register is set. cleared by hardware when reading kbf sfr by software. 3kbf3 keyboard line 3 flag set by hardware when the port line 3 detects a programmed level. it generates a keyboard interrupt request if the kbie.3 bit in kbie register is set. cleared by hardware when reading kbf sfr by software. 2kbf2 keyboard line 2 flag set by hardware when the port line 2 detects a programmed level. it generates a keyboard interrupt request if the kbie.2 bit in kbie register is set. must be cleared by software. 1kbf1 keyboard line 1 flag set by hardware when the port line 1 detects a programmed level. it generates a keyboard interrupt request if the kbie.1 bit in kbie register is set. cleared by hardware when reading kbf sfr by software. 0kbf0 keyboard line 0 flag set by hardware when the port line 0 detects a programmed level. it generates a keyboard interrupt request if the kbie.0 bit in kbie register is set. cleared by hardware when reading kbf sfr by software.
87 at89c5131a-l 4338e?usb?06/06 table 69. kbe register kbe - keyboard input enable register (9dh) reset value = 0000 0000b 76543210 kbe7 kbe6 kbe5 kbe4 kbe3 kbe2 kbe1 kbe0 bit number bit mnemonic description 7 kbe7 keyboard line 7 enable bit cleared to enable standard i/o pin. set to enable kbf.7 bit in kbf register to generate an interrupt request. 6 kbe6 keyboard line 6 enable bit cleared to enable standard i/o pin. set to enable kbf.6 bit in kbf register to generate an interrupt request. 5 kbe5 keyboard line 5 enable bit cleared to enable standard i/o pin. set to enable kbf.5 bit in kbf register to generate an interrupt request. 4 kbe4 keyboard line 4 enable bit cleared to enable standard i/o pin. set to enable kbf.4 bit in kbf register to generate an interrupt request. 3 kbe3 keyboard line 3 enable bit cleared to enable standard i/o pin. set to enable kbf.3 bit in kbf register to generate an interrupt request. 2 kbe2 keyboard line 2 enable bit cleared to enable standard i/o pin. set to enable kbf.2 bit in kbf register to generate an interrupt request. 1 kbe1 keyboard line 1 enable bit cleared to enable standard i/o pin. set to enable kbf.1 bit in kbf register to generate an interrupt request. 0 kbe0 keyboard line 0 enable bit cleared to enable standard i/o pin. set to enable kbf.0 bit in kbf register to generate an interrupt request.
88 at89c5131a-l 4338e?usb?06/06 table 70. kbls register kbls-keyboard level selector register (9ch) reset value = 0000 0000b 76543210 kbls7 kbls6 kbls5 kbls4 kbls3 kbls2 kbls1 kbls0 bit number bit mnemonic description 7kbls7 keyboard line 7 level selection bit cleared to enable a low level detection on port line 7. set to enable a high level detection on port line 7. 6kbls6 keyboard line 6 level selection bit cleared to enable a low level detection on port line 6. set to enable a high level detection on port line 6. 5kbls5 keyboard line 5 level selection bit cleared to enable a low level detection on port line 5. set to enable a high level detection on port line 5. 4kbls4 keyboard line 4 level selection bit cleared to enable a low level detection on port line 4. set to enable a high level detection on port line 4. 3kbls3 keyboard line 3 level selection bit cleared to enable a low level detection on port line 3. set to enable a high level detection on port line 3. 2kbls2 keyboard line 2 level selection bit cleared to enable a low level detection on port line 2. set to enable a high level detection on port line 2. 1kbls1 keyboard line 1 level selection bit cleared to enable a low level detection on port line 1. set to enable a high level detection on port line 1. 0kbls0 keyboard line 0 level selection bit cleared to enable a low level detection on port line 0. set to enable a high level detection on port line 0.
89 at89c5131a-l 4338e?usb?06/06 programmable led at89c5131a-l have up to 4 programmable led current sources, configured by the register ledcon. reset value = 00h table 71. ledcon register ledcon (s:f1h) led control register 76543210 led3 led2 led1 led0 bit number bit mnemonic description 7:6 led3 port led3 c onfiguration 0 0standard c51 port 01 2 ma current source when p3.7 is low 10 4 ma current source when p3.7 is low 11 10 ma current source when p3.7 is low 5:4 led2 port /led2 c onfiguration 00 standard c51 port 01 2 ma current source when p3.6 is low 10 4 ma current source when p3.6 is low 11 10 ma current source when p3.6 is low 3:2 led1 port/ led1 c onfiguration 00 standard c51 port 01 2 ma current source when p3.5 is low 10 4 ma current source when p3.5 is low 11 10 ma current source when p3.5 is low 1:0 led0 port/ led0 c onfiguration 00 standard c51 port 01 2 ma current source when p3.3 is low 10 4 ma current source when p3.3 is low 11 10 ma current source when p3.3 is low
90 at89c5131a-l 4338e?usb?06/06 serial peripheral interface (spi) the serial peripheral interface module (spi) allows full-duplex, synchronous, serial communication between the mcu and peripheral devices, including other mcus. features features of the spi module include the following: ? full-duplex, three-wire synchronous transfers ? master or slave operation ? eight programmable master clock rates ? serial clock with programmable polarity and phase ? master mode fault error flag with mcu interrupt capability ? write collision flag protection signal description figure 41 shows a typical spi bus configuration using one master controller and many slave peripherals. the bus is made of three wires connecting all the devices: figure 41. spi master/slaves interconnection the master device selects the individual slave devices by using four pins of a parallel port to control the four ss pins of the slave devices. master output slave input (mosi) this 1-bit signal is directly connected between the master device and a slave device. the mosi line is used to transfer data in series from the master to the slave. therefore, it is an output signal from the master, and an input signal to a slave. a byte (8-bit word) is transmitted most significant bit (msb) first, least significant bit (lsb) last. master input slave output (miso) this 1-bit signal is directly connected between the slave device and a master device. the miso line is used to transfer data in series from the slave to the master. therefore, it is an output signal from the slave, and an input signal to the master. a byte (8-bit word) is transmitted most significant bit (msb) first, least significant bit (lsb) last. spi serial clock (sck) this signal is used to synchronize the data movement both in and out the devices through their mosi and miso lines. it is driven by the master for eight clock cycles which allows to exchange one byte on the serial lines. slave select (ss ) each slave peripheral is selected by one slave select pin (ss ). this signal must stay low for any message for a slave. it is obvious that only one master (ss high level) can drive the network. the master may select each slave device by software through port slave 1 miso mosi sck ss miso mosi sck ss port 0 1 2 3 slave 3 miso mosi sck ss slave 4 miso mosi sck ss slave 2 miso mosi sck ss vdd master
91 at89c5131a-l 4338e?usb?06/06 pins (figure 41). to prevent bus conflicts on the miso line, only one slave should be selected at a time by the master for a transmission. in a master configuration, the ss line can be used in conjunction with the modf flag in the spi status register (spsta) to prevent multiple masters from driving mosi and sck (see section ?error conditions?, page 95). a high level on the ss pin puts the miso line of a slave spi in a high-impedance state. the ss pin could be used as a general-purpose if the following conditions are met: ? the device is configured as a master and the ssdis control bit in spcon is set. this kind of configuration can be found when only one master is driving the network and there is no way that the ss pin could be pulled low. therefore, the modf flag in the spsta will never be set (1) . ? the device is configured as a slave with cpha and ssdis control bits set (2) this kind of configuration can happen when the system comprises one master and one slave only. therefore, the device should always be selected and there is no reason that the master uses the ss pin to select the communicating slave device. notes: 1. clearing ssdis control bit does not clear modf. 2. special care should be taken not to set ssdis control bit when cpha =?0? because in this mode, the ss is used to start the transmission. baud rate in master mode, the baud rate can be selected from a baud rate generator which is con- trolled by three bits in the spcon register: spr2, spr1 and spr0. the master clock is chosen from one of seven clock rates resulting from the division of the internal clock by 2, 4, 8, 16, 32, 64 or 128. table 72 gives the different clock rates selected by spr2:spr1:spr0: table 72. spi master baud rate selection spr2 spr1 spr0 clock rate baud rate divisor (bd) 0 0 0 don?t use no brg 001 f clk periph /4 4 010 f clk periph /8 8 011 f clk periph /16 16 100 f clk periph /32 32 101 f clk periph /64 64 110 f clk periph /128 128 1 1 1 don?t use no brg
92 at89c5131a-l 4338e?usb?06/06 functional description figure 42 shows a detailed structure of the spi module. figure 42. spi module block diagram operating modes the serial peripheral interface can be configured as one of the two modes: master mode or slave mode. the configuration and initialization of the spi module is made through one register: ? the serial peripheral control register (spcon) once the spi is configured, the data exchange is made using: ?spcon ? the serial peripheral status register (spsta) ? the serial peripheral data register (spdat) during an spi transmission, data is simultaneously transmitted (shifted out serially) and received (shifted in serially). a serial clock line (sck) synchronizes shifting and sam- pling on the two serial data lines (mosi and miso). a slave select line (ss ) allows individual selection of a slave spi device; slave devices that are not selected do not interfere with spi bus activities. when the master device transmits data to the slave device via the mosi line, the slave device responds by sending data to the master device via the miso line. this implies full-duplex transmission with both data out and data in synchronized with the same clock (figure 43). shift register 0 1 2 3 4 5 6 7 internal bus pin control logic miso mosi sck m s clock logic clock divider clock select /4 /64 /128 spi interrupt request 8-bit bus 1-bit signa l ss fclk periph /32 /8 /16 receive data register spdat spi control spsta cpha spr0 spr1 cpol mstr ssdis spen spr2 spcon wcol modf spif ---- sserr
93 at89c5131a-l 4338e?usb?06/06 figure 43. full-duplex master/slave interconnection master mode the spi operates in master mode when the master bit, mstr (1) , in the spcon register is set. only one master spi device can initiate transmissions. software begins the trans- mission from a master spi module by writing to the serial peripheral data register (spdat). if the shift register is empty, the byte is immediately transferred to the shift register. the byte begins shifting out on mosi pin under the control of the serial clock, sck. simultaneously, another byte shifts in from the slave on the master?s miso pin. the transmission ends when the serial peripheral transfer data flag, spif, in spsta becomes set. at the same time that spif becomes set, the received byte from the slave is transferred to the receive data register in spdat. software clears spif by reading the serial peripheral status register ( spsta) with the spif bit set, and then reading the spdat. slave mode the spi operates in slave mode when the master bit, mstr (2) , in the spcon register is cleared. before a data transmission occurs, the slave select pin, ss , of the slave device must be set to?0?. ss must remain low until the transmission is complete. in a slave spi module, data enters the shift register under the control of the sck from the master spi module. after a byte enters the shift register, it is immediately transferred to the receive data register in spdat, and the spif bit is set. to prevent an overflow condition, slave software must then read the spdat before another byte enters the shift register (3) . a slave spi must complete the write to the spdat (shift register) at least one bus cycle before the master spi starts a transmission. if the write to the data register is late, the spi transmits the data already in the shift register from the previous transmission. transmission formats software can select any of four combinations of serial clock (sck) phase and polarity using two bits in the spcon: the clock polarity (cpol (4) ) and the clock phase (cpha 4 ). cpol defines the default sck line level in idle state. it has no significant effect on the transmission format. cpha defines the edges on which the input data are sampled and the edges on which the output data are shifted (figure 44 and figure 45). the clock phase and polarity should be identical for the master spi device and the com- municating slave device. 8-bit shift register spi clock generator master mcu 8-bit shift register miso miso mosi mosi sck sck vss vdd ss ss slave mcu 1. the spi module should be configured as a master before it is enabled (spen set). also the master spi should be configured before the slave spi. 2. the spi module should be configured as a slave before it is enabled (spen set). 3. the maximum frequency of the sck for an spi configured as a slave is the bus clock speed. 4. before writing to the cpol and cpha bits, the spi should be disabled (spen =?0?).
94 at89c5131a-l 4338e?usb?06/06 figure 44. data transmission format (cpha = 0) figure 45. data transmission format (cpha = 1) figure 46. cpha/ss timing as shown in figure 45, the first sck edge is the msb capture strobe. therefore the slave must begin driving its data before the first sck edge, and a falling edge on the ss pin is used to start the transmission. the ss pin must be toggled high and then low between each byte transmitted (figure 42). figure 46 shows an spi transmission in which cpha is?1?. in this case, the master begins driving its mosi pin on the first sck edge. therefore the slave uses the first sck edge as a start transmission signal. the ss pin can remain low between transmis- sions (figure 41). this format may be preferable in systems having only one master and only one slave driving the miso data line. msb bit6 bit5 bit4 bit3 bit2 bit1 lsb bit6 bit5 bit4 bit3 bit2 bit1 msb lsb 13 2 45678 capture point ss (to slave) miso (from slave) mosi (from master) sck (cpol = 1) sck (cpol = 0) spen (internal) sck cycle number msb bit6 bit5 bit4 bit3 bit2 bit1 lsb bit6 bit5 bit4 bit3 bit2 bit1 msb lsb 13 2 45678 capture point ss (to slave) miso (from slave) mosi (from master) sck (cpol = 1) sck (cpol = 0) spen (internal) sck cycle number byte 1 byte 2 byte 3 miso/mosi master ss slave ss (cpha = 1) slave ss (cpha = 0)
95 at89c5131a-l 4338e?usb?06/06 error conditions the following flags in the spsta signal spi error c onditions: mode fault (modf) mode fault error in master mode spi indicates that the level on the slave select (ss ) pin is inconsistent with the actual mode of the device. modf is set to warn that there may have a multi-master conflict for system control. in this case, the spi system is affected in the following ways: ? an spi receiver/error cpu interrupt request is generated, ? the spen bit in spcon is cleared. this disable the spi, ? the mstr bit in spcon is cleared when ss disable (ssdis) bit in the spcon register is cleared, the modf flag is set when the ss signal becomes ?0?. however, as stated before, for a system with one master, if the ss pin of the master device is pulled low, there is no way that another master attempt to drive the network. in this case, to prevent the modf flag from being set, software can set the ssdis bit in the spcon register and therefore making the ss pin as a general-purpose i/o pin. clearing the modf bit is accomplished by a read of spsta register with modf bit set, followed by a write to the spcon register. spen control bit may be restored to its orig- inal set state after the modf bit has been cleared. write collision (wcol) a write collision (wcol) flag in the spsta is set when a write to the spdat register is done during a transmit sequence. wcol does not cause an interruption, and the transfer continues uninterrupted. clearing the wcol bit is done through a software sequence of an access to spsta and an access to spdat. overrun condition an overrun condition occurs when the master device tries to send several data bytes and the slave devise has not cleared the spif bit issuing from the previous data byte transmitted. in this case, the receiver buffer contains the byte sent after the spif bit was last cleared. a read of the spdat returns this byte. all others bytes are lost. this condition is not detected by the spi peripheral. interrupts two spi status flags can generate a cpu interrupt requests: table 73. spi interrupts serial peripheral data transfer flag, spif: this bit is set by hardware when a transfer has been completed. spif bit generates transmitter cpu interrupt requests. mode fault flag, modf: this bit becomes set to indicate that the level on the ss is inconsistent with the mode of the spi. modf with ssdis reset, generates receiver/error cpu interrupt requests. figure 47 gives a logical view of the above statements. flag request spif (sp data transfer) spi transmitter interrupt request modf (mode fault) spi receiver/error interrupt request (if ssdis = ?0?)
96 at89c5131a-l 4338e?usb?06/06 figure 47. spi interrupt requests generation registers there are three registers in the module that provide control, status and data storage functions. these registers are describes in the following paragraphs. serial peripheral control register (spcon) ? the serial peripheral control register does the following: ? selects one of the master clock rates ? configure the spi module as master or slave ? selects serial clock polarity and phase ? enables the spi module ? frees the ss pin for a general-purpose table 74 describes this register and explains the use of each bit. ssdis modf cpu interrupt request spi receiver/error cpu interrupt request spi transmitter spi cpu interrupt request spif table 74. spcon register 76543210 spr2 spen ssdis mstr cpol cpha spr1 spr0 bit number bit mnemonic description 7spr2 serial peripheral rate 2 bit with spr1 and spr0 define the clock rate. 6 spen serial peripheral enable cleared to disable the spi interface. set to enable the spi interface. 5 ssdis ss disable cleared to enable ss in both master and slave modes. set to disable ss in both master and slave modes. in slave mode, this bit has no effect if cpha = ?0?. 5mstr serial peripheral master cleared to configure the spi as a slave. set to configure the spi as a master. 4cpol clock polarity cleared to have the sck set to ?0? in idle state. set to have the sck set to ?1? in idle state. 3cpha clock phase cleared to have the data sampled when the sck leaves the idle state (see cpol). set to have the data sampled when the sck returns to idle state (see cpol).
97 at89c5131a-l 4338e?usb?06/06 reset value = 0001 0100b not bit addressable serial peripheral status register (spsta) the serial peripheral status register contains flags to signal the following conditions: ? data transfer complete ? write collision ? inconsistent logic level on ss pin (mode fault error) table 75 describes the spsta register and explains the use of every bit in the register. table 75. spsta register spsta - serial peri pheral status and control register (0c4h) 2spr1 spr2 spr1 spr0 serial peripheral rate 000reserved 00 1f clk periph/ 4 010 f clk periph/ 8 011f clk periph/ 16 100f clk periph/ 32 10 1f clk periph/ 64 110f clk periph/ 128 1 11reserved 1spr0 bit number bit mnemonic description table 1. 76543210 spif wcol sserr modf - - - - bit number bit mnemonic description 7 spif serial peripheral data transfer flag cleared by hardware to indicate data transfer is in progress or has been approved by a clearing sequence. set by hardware to indicate that the data transfer has been completed. 6wcol write collision flag cleared by hardware to indicate that no collision has occurred or has been approved by a clearing sequence. set by hardware to indicate that a collision has been detected. 5 sserr synchronous serial slave error flag set by hardware when ss is de- asserted before the end of a received data. cleared by disabling the spi (clearing spen bit in spcon). 4modf mode fault cleared by hardware to indicate that the ss pin is at appropriate logic level, or has been approved by a clearing sequence. set by hardware to indicate that the ss pin is at inappropriate logic level. 3- reserved the value read from this bit is indeterminate. do not set this bit
98 at89c5131a-l 4338e?usb?06/06 reset value = 00x0 xxxxb not bit addressable serial peripheral data register (spdat) the serial peripheral data register (table 76) is a read/write buffer for the receive data register. a write to spdat places data directly into the shift register. no transmit buffer is available in this model. a read of the spdat returns the value located in the receive buffer and not the content of the shift register. table 76. spdat register spdat - serial peripheral data register (0c5h) reset value = indeterminate r7:r0: receive data bits spcon, spsta and spdat registers may be read and written at any time while there is no on-going exchange. however, special care should be taken when writing to them while a transmission is on-going: ? do not change spr2, spr1 and spr0 ? do not change cpha and cpol ? do not change mstr ? clearing spen would immediately disable the peri pheral ? writing to the spdat will cause an overflow 2- reserved the value read from this bit is indeterminate. do not set this bit 1- reserved the value read from this bit is indeterminate. do not set this bit. 0- reserved the value read from this bit is indeterminate. do not set this bit. bit number bit mnemonic description table 2. 76543210 r7 r6 r5 r4 r3 r2 r1 r0
99 at89c5131a-l 4338e?usb?06/06 two wire interface ( twi ) this section describes the 2-wire interface. the 2-wire bus is a bi-directional 2-wire serial communication standard. it is designed primarily for simple but efficient integrated circuit (ic) control. the system is comprised of two lines, scl (serial clock) and sda (serial data) that carry information between the ics connected to them. the serial data transfer is limited to 100 kbit/s in standard mode. various communication configuration can be designed using this bus. figure 48 shows a typical 2-wire bus configuration. all the devices connected to the bus can be master and slave. figure 48. 2-wire bus configuration scl sda device2 device1 devicen device3 ...
100 at89c5131a-l 4338e?usb?06/06 figure 49. block diagram address register comparator timing & control logic arbitration & sink logic serial clock generator shift register control register status register status decoder input filter output stage input filter output stage ack status bits 8 8 7 8 internal bus timer 1 overflow f clk periph /4 interrupt sda scl ssadr sscon ssdat sscs
101 at89c5131a-l 4338e?usb?06/06 description the cpu interfaces to the 2-wire logic via the following four 8-bit special function regis- ters: the synchronous serial control r egister (sscon; table 86), the synchronous serial data register (ssdat; table 87), the synchronous serial control and status reg- ister (sscs; table 88) and the synchronous serial address register (ssadr table 89). sscon is used to enable the twi interface, to program the bit rate (see table 79), to enable slave modes, to acknowledge or not a received data, to send a start or a stop condition on the 2-wire bus, and to acknowledge a serial interrupt. a hardware reset disables the twi module. sscs contains a status code which reflects the status of the 2-wire logic and the 2-wire bus. the three least significant bits are always zero. the five most significant bits con- tains the status code. there are 26 possible status codes. when sscs contains f8h, no relevant state information is available and no serial interrupt is requested. a valid sta- tus code is available in sscs one machine cycle after si is set by hardware and is still present one machine cycle after si has been reset by software. to table 85. give the status for the master modes and miscellaneous states. ssdat contains a byte of serial data to be transmitted or a byte which has just been received. it is addressable while it is not in process of shifting a byte. this occurs when 2-wire logic is in a defined state and the serial interrupt flag is set. data in ssdat remains stable as long as si is set. while data is being shifted out, data on the bus is simultaneously shifted in; ssdat always contains the last byte present on the bus. ssadr may be loaded with the 7-bit slave address (7 most significant bits) to which the twi module will respond when programmed as a slave transmitter or receiver. the lsb is used to enable general call address (00h) recognition. figure 50 shows how a data transfer is accomplished on the 2-wire bus. figure 50. complete data transfer on 2-wire bus the four operating modes are: ? master transmitter ? master receiver ? slave transmitter ? slave receiver data transfer in each mode of operation is shown in table to table 85 and figure 51. to figure 54.. these figures contain the following abbreviations: s : start condition r : read bit (high level at sda) w: write bit (low level at sda) sda scl s start condition msb 12 7 89 ack acknowledgement signal from receiver acknowledgement signal from receiver 12 3-8 9 ack stop condition p clock line held low while interrupts are serviced
102 at89c5131a-l 4338e?usb?06/06 a: acknowledge bit (low level at sda) a : not acknowledge bit (high level at sda) data: 8-bit data byte p : stop condition in figure 51 to figure 54, circles are used to indicate when the serial interrupt flag is set. the numbers in the circles show the status code held in sscs. at these points, a ser- vice routine must be executed to continue or complete the serial transfer. these service routines are not critical since the serial transfer is suspended until the serial interrupt flag is cleared by software. when the serial interrupt routine is entered, the status code in sscs is used to branch to the appropriate service routine. for each status code, the required software action and details of the following serial transfer are given in table to table 85. master transmitter mode in the master transmitter mode, a number of data bytes are transmitted to a slave receiver (figure 51). before the master transmitter mode can be entered, sscon must be initialised as follows: cr0, cr1 and cr2 define the internal serial bit rate if external bit rate generator is not used. ssie must be set to enable twi. sta, sto and si must be cleared. the master transmitter mode may now be entered by setting the sta bit. the 2-wire logic will now test the 2-wire bus and generate a start condition as soon as the bus becomes free. when a start condition is transmitted, the serial interrupt flag (si bit in sscon) is set, and the status code in sscs will be 08h. this status must be used to vector to an interrupt routine that loads ssdat with the slave address and the data direction bit (sla+w). when the slave address and the direction bit have been transmitted and an acknowl- edgement bit has been received, si is set again and a number of status code in sscs are possible. there are 18h, 20h or 38h for the master mode and also 68h, 78h or b0h if the slave mode was enabled (aa=logic 1). the appropriate action to be taken for each of these status code is detailed in table . this scheme is repeated until a stop condi- tion is transmitted. ssie, cr2, cr1 and cr0 are not affected by the serial transfer and are referred to table 7 to table 11. after a repeated start condition (state 10h) the twi module may switch to the master receiver mode by loading ssdat with sla+r. master receiver mode in the master receiver mode, a number of data bytes are received from a slave transmit- ter (figure 52). the transfer is initialized as in the master transmitter mode. when the start condition has been transmitted, the interrupt routine must load ssdat with the 7-bit slave address and the data direction bit (sla+r). the serial interrupt flag si must then be cleared before the serial transfer can continue. when the slave address and the direction bit have been transmitted and an acknowl- edgement bit has been received, the serial interrupt flag is set again and a number of table 77. sscon initialization cr2 ssie sta sto si aa cr1 cr0 bit rate 1 0 0 0 x bit rate bit rate
103 at89c5131a-l 4338e?usb?06/06 status code in sscs are possible. there are 40h, 48h or 38h for the master mode and also 68h, 78h or b0h if the slave mode was enabled (aa=logic 1). the appropriate action to be taken for each of these status code is detailed in table . this scheme is repeated until a stop condition is transmitted. ssie, cr2, cr1 and cr0 are not affected by the serial transfer and are referred to table 7 to table 11. after a repeated start condition (state 10h) the twi module may switch to the master transmitter mode by loading ssdat with sla+w. slave receiver mode in the slave receiver mode, a number of data bytes are received from a master transmit- ter (figure 53). to initiate the slave receiver mode, ssadr and sscon must be loaded as follows: the upper 7 bits are the address to which the twi module will re spond when addressed by a master. if the lsb (gc) is set the twi module will respond to the general call address (00h); otherwise it ignores the general call address. cr0, cr1 and cr2 have no effect in the slave mode. ssie must be set to enable the twi. the aa bit must be set to enable the own slave address or the general call address acknowledgement. sta, sto and si must be cleared. when ssadr and sscon have been initialised, the twi module waits until it is addressed by its own slave address followed by the data direction bit which must be at logic 0 (w) for the twi to operate in the slave receiver mode. after its own slave address and the w bit have been received, the serial interrupt flag is set and a valid sta- tus code can be read from sscs. this status code is used to vector to an interrupt service routine.the appropriate action to be taken for each of these status code is detailed in table . the slave receiver mode may also be entered if arbitration is lost while twi is in the master mode (states 68h and 78h). if the aa bit is reset during a transfer, twi module will return a not acknowledge (logic 1) to sda after the next received data byte. while aa is reset, the twi module does not respond to its own slave address. however, the 2-wire bus is still monitored and address recognition may be resume at any time by setting aa. this means that the aa bit may be used to temporarily isolate the module from the 2-wire bus. slave transmitter mode in the slave transmitter mode, a number of data bytes are transmitted to a master receiver (figure 54). data transfer is initialized as in the slave receiver mode. when ssadr and sscon have been initialized, the twi module waits until it is addressed by its own slave address followed by the data direction bit which must be at logic 1 (r) for twi to operate in the slave transmitter mode. after its own slave address and the r bit table 78. ssadr: slave receiver mode initialization a6 a5 a4 a3 a2 a1 a0 gc own slave address table 79. sscon: slave receiver mode initialization cr2 ssie sta sto si aa cr1 cr0 bit rate 1 0 0 0 1 bit rate bit rate
104 at89c5131a-l 4338e?usb?06/06 have been received, the serial interrupt flag is set and a valid status code can be read from sscs. this status code is used to vector to an interrupt service routine. the appro- priate action to be taken for each of these status code is detailed in table . the slave transmitter mode may also be entered if arbitration is lost while the twi module is in the master mode. if the aa bit is reset during a transfer, the twi module will transmit the last byte of the transfer and enter state c0h or c8h. the twi module is switched to the not addressed slave mode and will ignore the master receiver if it continues the transfer. thus the mas- ter receiver receives all 1?s as serial data. while aa is reset, the twi module does not respond to its own slave address. however, the 2-wire bus is still monitored and address recognition may be resume at any time by setting aa. this means that the aa bit may be used to temporarily isolate the twi module from the 2-wire bus. miscellaneous states there are two sscs codes that do not correspond to a define twi hardware state (table 85 ). these codes are discuss hereafter. status f8h indicates that no relevant information is available because the serial interrupt flag is not set yet. this occurs between other states and when the twi module is not involved in a serial transfer. status 00h indicates that a bus error has occurred during a twi serial transfer. a bus error is caused when a start or a stop condition occurs at an illegal position in the format frame. examples of such illegal pos itions happen during the serial transfer of an address byte, a data byte, or an acknowledge bit. when a bus error occurs, si is set. to recover from a bus error, the sto flag must be set and si must be cleared. this causes the twi module to enter the not addressed slave mode and to clear the sto flag (no other bits in sscon are affected). the sda and scl lines are released and no stop condition is transmitted. notes the twi module interfaces to the external 2-wire bus via two port pins: scl (serial clock line) and sda (serial data line). to avoid low level asserting on these lines when the twi module is enabled, the output latches of sda and slc must be set to logic 1. table 80. bit frequency configuration bit frequency ( khz) cr2 cr1 cr0 f osca = 12 mhz f osca = 16 mhz f osca divided by 0 0 0 47 62.5 256 0 0 1 53.5 71.5 224 0 1 0 62.5 83 192 0 1 1 75 100 160 100 - - unused 1 0 1 100 133.3 120 1 1 0 200 266.6 60 1 1 1 0.5 <. < 62.5 0.67 <. < 83 timer 1 in mode 2 can be used as twi baudrate generator with the following formula: 96.(256-?timer1 reload value?)
105 at89c5131a-l 4338e?usb?06/06 figure 51. format and state in the master transmitter mode sslawa data ap 08h 18h 28h mt sslaw ap ap r mr 10h 20h 30h a or a continues 38h 38h a continues 68h other master other master 78h b0h to corresponding states in slave mode successfull transmission to a slave receiver next transfer started with a repeated start condition not acknowledge received after the slave address not acknowledge received after a data arbitration lost in slave address or data byte arbitration lost and addressed as slave byte a or a continues other master data a n from master to slave from slave to master any number of data bytes and their associated acknowledge bits this number (contained in sscs) corresponds to a defined state of the 2-wire bus
106 at89c5131a-l 4338e?usb?06/06 table 81. status in master transmitter mode status code sssta status of the two- wire bus and two- wire hardware application software response next action taken by two-wire hardware to/from ssdat to sscon sssta sssto ssi ssaa 08h a start condition has been transmitted write sla+w x 0 0 x sla+w will be transmitted. 10h a repeated start condition has been transmitted write sla+w write sla+r x x 0 0 0 0 x x sla+w will be transmitted. sla+r will be transmitted. logic will switch to master receiver mode 18h sla+w has been transmitted; ack has been received write data byte no ssdat action no ssdat action no ssdat action 0 1 0 1 0 0 1 1 0 0 0 0 x x x x data byte will be transmitted. repeated start will be transmitted. stop condition will be transmitted and sssto flag will be reset. stop condition followed by a start condition will be transmitted and sssto flag will be reset. 20h sla+w has been transmitted; not ack has been received write data byte no ssdat action no ssdat action no ssdat action 0 1 0 1 0 0 1 1 0 0 0 0 x x x x data byte will be transmitted. repeated start will be transmitted. stop condition will be transmitted and sssto flag will be reset. stop condition followed by a start condition will be transmitted and sssto flag will be reset. 28h data byte has been transmitted; ack has been received write data byte no ssdat action no ssdat action no ssdat action 0 1 0 1 0 0 1 1 0 0 0 0 x x x x data byte will be transmitted. repeated start will be transmitted. stop condition will be transmitted and sssto flag will be reset. stop condition followed by a start condition will be transmitted and sssto flag will be reset. 30h data byte has been transmitted; not ack has been received write data byte no ssdat action no ssdat action no ssdat action 0 1 0 1 0 0 1 1 0 0 0 0 x x x x data byte will be transmitted. repeated start will be transmitted. stop condition will be transmitted and sssto flag will be reset. stop condition followed by a start condition will be transmitted and sssto flag will be reset. 38h arbitration lost in sla+w or data bytes no ssdat action no ssdat action 0 1 0 0 0 0 x x two-wire bus will be released and not addressed slave mode will be entered. a start condition will be transmitted when the bus becomes free.
107 at89c5131a-l 4338e?usb?06/06 figure 52. format and state in the master receiver mode sslar a data 08h 40h 58h sslar ap w mt 10h 48h a or a continues 38h 38h a continues 68h other master other master 78h b0h to corresponding states in slave mode successfull transmission to a slave receiver next transfer started with a repeated start condition not acknowledge received after the slave address arbitration lost and addressed as slave a continues other master n from master to slave from slave to master any number of data bytes and their associated acknowledge bits this number (contained in sscs) corresponds to a defined state of the 2-wire bus a data p a 50h mr arbitration lost in slave address or acknowledge bit data a
108 at89c5131a-l 4338e?usb?06/06 table 82. status in master receiver mode status code sssta status of the two- wire bus and two- wire hardware application software response next action taken by two-wire hardware to/from ssdat to sscon sssta sssto ssi ssaa 08h a start condition has been transmitted write sla+r x 0 0 x sla+r will be transmitted. 10h a repeated start condition has been transmitted write sla+r write sla+w x x 0 0 0 0 x x sla+r will be transmitted. sla+w will be transmitted. logic will switch to master transmitter mode. 38h arbitration lost in sla+r or not ack bit no ssdat action no ssdat action 0 1 0 0 0 0 x x two-wire bus will be released and not addressed slave mode will be entered. a start condition will be transmitted when the bus becomes free. 40h sla+r has been transmitted; ack has been received no ssdat action no ssdat action 0 0 0 0 0 0 0 1 data byte will be received and not ack will be returned. data byte will be received and ack will be returned. 48h sla+r has been transmitted; not ack has been received no ssdat action no ssdat action no ssdat action 1 0 1 0 1 1 0 0 0 x x x repeated start will be transmitted. stop condition will be transmitted and sssto flag will be reset. stop condition followed by a start condition will be transmitted and sssto flag will be reset. 50h data byte has been received; ack has been returned read data byte read data byte 0 0 0 0 0 0 0 1 data byte will be received and not ack will be returned. data byte will be received and ack will be returned. 58h data byte has been received; not ack has been returned read data byte read data byte read data byte 1 0 1 0 1 1 0 0 0 x x x repeated start will be transmitted. stop condition will be transmitted and sssto flag will be reset. stop condition followed by a start condition will be transmitted and sssto flag will be reset.
109 at89c5131a-l 4338e?usb?06/06 figure 53. format and state in the slave receiver mode sslawa data a data p or s a p or s a general call a data a data p or s a a 60h 68h 80h 80h a0h 88h 70h 90h 90h a0h p or s a 98h a 78h data a n from master to slave from slave to master any number of data bytes and their associated acknowledge bits this number (contained in sscs) corresponds to a defined state of the 2-wire bus reception of the own slave address and one or more data bytes. all are acknowledged. last data byte received is not acknowledged. arbitration lost as master and addressed as slave reception of the general call address and one or more data bytes. last data byte received is not acknowledged. arbitration lost as master and addressed as slave by general call
110 at89c5131a-l 4338e?usb?06/06 table 83. status in slave receiver mode status code (sscs) status of the 2-wire bus and 2-wire hardware application software response next action taken by 2-wire software to/from ssdat to sscon sta sto si aa 60h own sla+w has been received; ack has been returned no ssdat action or no ssdat action x x 0 0 0 0 0 1 data byte will be received and not ack will be returned data byte will be received and ack will be returned 68h arbitration lost in sla+r/w as master; own sla+w has been received; ack has been returned no ssdat action or no ssdat action x x 0 0 0 0 0 1 data byte will be received and not ack will be returned data byte will be received and ack will be returned 70h general call address has been received; ack has been returned no ssdat action or no ssdat action x x 0 0 0 0 0 1 data byte will be received and not ack will be returned data byte will be received and ack will be returned 78h arbitration lost in sla+r/w as master; general call address has been received; ack has been returned no ssdat action or no ssdat action x x 0 0 0 0 0 1 data byte will be received and not ack will be returned data byte will be received and ack will be returned 80h previously addressed with own sla+w; data has been received; ack has been returned no ssdat action or no ssdat action x x 0 0 0 0 0 1 data byte will be received and not ack will be returned data byte will be received and ack will be returned 88h previously addressed with own sla+w; data has been received; not ack has been returned read data byte or read data byte or read data byte or read data byte 0 0 1 1 0 0 0 0 0 0 0 0 0 1 0 1 switched to the not addressed slave mode; no recognition of own sla or gca switched to the not addressed slave mode; own sla will be recognised; gca will be recognised if gc=logic 1 switched to the not addressed slave mode; no recognition of own sla or gca. a start condition will be transmitted when the bus becomes free switched to the not addressed slave mode; own sla will be recognised; gca will be recognised if gc=logic 1. a start condition will be transmitted when the bus becomes free 90h previously addressed with general call; data has been received; ack has been returned read data byte or read data byte x x 0 0 0 0 0 1 data byte will be received and not ack will be returned data byte will be received and ack will be returned
111 at89c5131a-l 4338e?usb?06/06 98h previously addressed with general call; data has been received; not ack has been returned read data byte or read data byte or read data byte or read data byte 0 0 1 1 0 0 0 0 0 0 0 0 0 1 0 1 switched to the not addressed slave mode; no recognition of own sla or gca switched to the not addressed slave mode; own sla will be recognised; gca will be recognised if gc=logic 1 switched to the not addressed slave mode; no recognition of own sla or gca. a start condition will be transmitted when the bus becomes free switched to the not addressed slave mode; own sla will be recognised; gca will be recognised if gc=logic 1. a start condition will be transmitted when the bus becomes free a0h a stop condition or repeated start condition has been received while still addressed as slave no ssdat action or no ssdat action or no ssdat action or no ssdat action 0 0 1 1 0 0 0 0 0 0 0 0 0 1 0 1 switched to the not addressed slave mode; no recognition of own sla or gca switched to the not addressed slave mode; own sla will be recognised; gca will be recognised if gc=logic 1 switched to the not addressed slave mode; no recognition of own sla or gca. a start condition will be transmitted when the bus becomes free switched to the not addressed slave mode; own sla will be recognised; gca will be recognised if gc=logic 1. a start condition will be transmitted when the bus becomes free table 83. status in slave receiver mode (continued) status code (sscs) status of the 2-wire bus and 2-wire hardware application software response next action taken by 2-wire software to/from ssdat to sscon sta sto si aa
112 at89c5131a-l 4338e?usb?06/06 figure 54. format and state in the slave transmitter mode sslar a data a data p or s a a8h b8h c0h p or s a c8h all 1?s a b0h data a n from master to slave from slave to master any number of data bytes and their associated acknowledge bits this number (contained in sscs) corresponds to a defined state of the 2-wire bus reception of the own slave address and one or more data bytes arbitration lost as master and addressed as slave last data byte transmitted. switched to not addressed slave (aa=0) table 84. status in slave transmitter mode status code (sscs) status of the 2-wire bus and 2-wire hardware application software response next action taken by 2-wire software to/from ssdat to sscon sta sto si aa a8h own sla+r has been received; ack has been returned load data byte or load data byte x x 0 0 0 0 0 1 last data byte will be transmitted and not ack will be received data byte will be transmitted and ack will be received b0h arbitration lost in sla+r/w as master; own sla+r has been received; ack has been returned load data byte or load data byte x x 0 0 0 0 0 1 last data byte will be transmitted and not ack will be received data byte will be transmitted and ack will be received b8h data byte in ssdat has been transmitted; not ack has been received load data byte or load data byte x x 0 0 0 0 0 1 last data byte will be transmitted and not ack will be received data byte will be transmitted and ack will be received
113 at89c5131a-l 4338e?usb?06/06 table 85. miscellaneous status c0h data byte in ssdat has been transmitted; not ack has been received no ssdat action or no ssdat action or no ssdat action or no ssdat action 0 0 1 1 0 0 0 0 0 0 0 0 0 1 0 1 switched to the not addressed slave mode; no recognition of own sla or gca switched to the not addressed slave mode; own sla will be recognised; gca will be recognised if gc=logic 1 switched to the not addressed slave mode; no recognition of own sla or gca. a start condition will be transmitted when the bus becomes free switched to the not addressed slave mode; own sla will be recognised; gca will be recognised if gc=logic 1. a start condition will be transmitted when the bus becomes free c8h last data byte in ssdat has been transmitted (aa=0); ack has been received no ssdat action or no ssdat action or no ssdat action or no ssdat action 0 0 1 1 0 0 0 0 0 0 0 0 0 1 0 1 switched to the not addressed slave mode; no recognition of own sla or gca switched to the not addressed slave mode; own sla will be recognised; gca will be recognised if gc=logic 1 switched to the not addressed slave mode; no recognition of own sla or gca. a start condition will be transmitted when the bus becomes free switched to the not addressed slave mode; own sla will be recognised; gca will be recognised if gc=logic 1. a start condition will be transmitted when the bus becomes free table 84. status in slave transmitter mode (continued) status code (sscs) status of the 2-wire bus and 2-wire hardware application software response next action taken by 2-wire software to/from ssdat to sscon sta sto si aa status code (sscs) status of the 2-wire bus and 2-wire hardware application software response next action taken by 2-wire software to/from ssdat to sscon sta sto si aa f8h no relevant state information available; si= 0 no ssdat action no sscon action wait or proceed current transfer 00h bus error due to an illegal start or stop condition no ssdat action 010x only the internal hardware is affected, no stop condition is sent on the bus. in all cases, the bus is released and sto is reset.
114 at89c5131a-l 4338e?usb?06/06 registers table 86. sscon register sscon - synchronous serial control register (93h) 76543210 cr2 ssie sta sto si aa cr1 cr0 bit number bit mnemonic description 7 cr2 control rate bit 2 see . 6 ssie synchronous serial interface enable bit clear to disable sslc. set to enable sslc. 5sta start flag set to send a start condition on the bus. 4st0 stop flag set to send a stop condition on the bus. 3si synchronous serial interrupt flag set by hardware when a serial interrupt is requested. must be cleared by software to acknowledge interrupt. 2aa assert acknowledge flag clear in master and slave receiver modes, to force a not acknowledge (high level on sda). clear to disable sla or gca recognition. set to recognise sla or gca (if gc set) for entering slave receiver or transmitter modes. set in master and slave receiver modes, to force an acknowledge (low level on sda). this bit has no effect when in master transmitter mode. 1 cr1 control rate bit 1 see table 80 0 cr0 control rate bit 0 see table 80 table 87. ssdat (095h) - synchronous serial data register (read/write) sd7 sd6 sd5 sd4 sd3 sd2 sd1 sd0 76543210 bit number bit mnemonic description 7 sd7 address bit 7 or data bit 7. 6 sd6 address bit 6 or data bit 6. 5 sd5 address bit 5 or data bit 5. 4 sd4 address bit 4 or data bit 4. 3 sd3 address bit 3 or data bit 3. 2 sd2 address bit 2 or data bit 2.
115 at89c5131a-l 4338e?usb?06/06 1 sd1 address bit 1 or data bit 1. 0 sd0 address bit 0 (r/w) or data bit 0. table 88. sscs (094h) read - synchronous serial control and status register 76543210 sc4 sc3 sc2 sc1 sc0 0 0 0 bit number bit mnemonic description 00always zero 10always zero 20always zero 3sc0 status code bit 0 see table 81 to table 85 4sc1 status code bit 1 see table 81 to table 85 5sc2 status code bit 2 see table 81 to table 85 6sc3 status code bit 3 see table 81 to table 85 7sc4 status code bit 4 see table 81 to table 85 table 89. ssadr (096h) - synchronous serial address register (read/write) 76543210 a7 a6 a5 a4 a3 a2 a1 a0 bit number bit mnemonic description 7a7 slave address bit 7. 6a6 slave address bit 6. 5a5 slave address bit 5. 4a4 slave address bit 4. 3a3 slave address bit 3. 2a2 slave address bit 2. 1a1 slave address bit 1. 0gc general call bit clear to disable the general call address recognition. set to enable the general call address recognition. bit number bit mnemonic description
116 at89c5131a-l 4338e?usb?06/06 usb controller . description the usb device controller provides the hardware that the at89c5131 needs to inter- face a usb link to a data flow stored in a double port memory (dpram). the usb controller requires a 48 mhz 0.25% reference clock, which is the output of the at89c5131 pll (see section ?pll?, page 14) divided by a clock prescaler. this clock is used to generate a 12 mhz full-speed bit clock from the received usb differen- tial data and to transmit data according to full speed usb device tolerance. clock recovery is done by a digital phase locked loop (dpll) block, which is compliant with the jitter specification of the usb bus. the serial interface engine (sie) block performs nrzi encoding and decoding, bit stuff- ing, crc generation and checking, and th e serial-parallel data conversion. the universal function interface (ufi) realizes the interface between the data flow and the dual port ram. figure 55. usb device controller block diagram sie dpll usb d+/d- buffer ufi 12 mhz 48 mhz +/- 0.25% d+ up to 48 mhz uc_sysclk c51 microcontroller interface d-
117 at89c5131a-l 4338e?usb?06/06 serial interface engine (sie) the sie performs the following functions: ? nrzi data encoding and decoding. ? bit stuffing and un-stuffing. ? crc generation and checking. ? handshakes. ? token type identifying. ? address checking. ? clock generation (via dpll). figure 56. sie block diagram end of packet detection start of packet detection d+ d- clock recovery sync detection pid decoder address decoder serial to parallel conversion crc5 and crc16 generation/check usb pattern generator parallel to serial converter bit stuffing nrzi converter crc16 generator nrzi ?nrz bit un-stuffing packet bit counter clk48 (48 mhz) sysclk (12 mhz) datain [7:0] dataout 8 8
118 at89c5131a-l 4338e?usb?06/06 function interface unit (fiu) the function interface unit provides the interface between the at89c5131 and the sie. it manages transactions at the packet level with minimal intervention from the device firmware, which reads and writes the endpoint fifos. figure 57. ufi block diagram figure 58. minimum intervention from the usb device firmware transfer control fsm dpr control usb side csreg 0 to 7 registers bank dpr control mp side fiu user dpram up to 48 mhz uc_sysclk c51 microcontrolle r interface asynchronous information transfer endpoint 0 endpoint 1 endpoint 2 endpoint 3 sie dpll endpoint 4 endpoint 5 endpoint 6 out transactions: host ufi c51 out data0 (n bytes) ack endpoint fifo read (n bytes) out data1 nack out data1 ack in transactions: host ufi c51 in ack endpoint fifo write in data1 nack interrupt c51 in data1 interrupt c51 endpoint fifo write
119 at89c5131a-l 4338e?usb?06/06 configuration general configuration ? usb controller enable before any usb transaction, the 48 mhz required by the usb controller must be correctly generated (see ?clock controller? on page 13.). the usb controller will be then enabled by setting the eusb bit in the usbcon register. ? set address after a reset or a usb reset, the software has to set the fen (function enable) bit in the usbaddr register. this action will allow the usb controller to answer to the requests sent at the address 0. when a set_address request has been received, the usb controller must only answer to the address defined by the request. the new address will be stored in the usbaddr register. the fen bit and the fadden bit in the usbcon register will be set to allow the usb controller to answer only to requests sent at the new address. ? set configuration the confg bit in the usbcon register has to be set after a set_configuration request with a non-zero value. otherwise, this bit has to be cleared. endpoint configuration ? selection of an endpoint the endpoint register access is performed using the uepnum register. the registers ? uepstax ? uepconx ?uepdatx ?ubyctlx ? ubycthx these registers correspond to the endpoint whose number is stored in the uep- num register. to select an endpoint, the firmware has to write the endpoint number in the uepnum register. figure 59. endpoint selection uepnum endpoint 0 endpoint 6 uepsta0 uepcon0 uepdat0 uepsta6 uepcon6 uepdat6 0 1 2 3 4 5 6 sfr registers uepstax uepconx uepdatx x ubycth0 ubyctl0 ubycth6 ubyctl6 ubycthx ubyctlx
120 at89c5131a-l 4338e?usb?06/06 ? endpoint enable before using an endpoint, th is one will be enabled by setting the epen bit in the uepconx register. an endpoint which is not enabled won?t answer to any usb request. the default control endpoint (endpoint 0) will always be enabled in order to answer to usb standard requests. ? endpoint type configuration all standard endpoints can be configured in control, bulk, interrupt or isochronous mode. the ping-pong endpoints can be configured in bulk, interrupt or isochronous mode. the configuration of an endpoint is performed by setting the field eptype with the following values: ? control:eptype = 00b ? isochronous:ept ype = 01b ? bulk:eptype = 10b ? interrupt:eptype = 11b the endpoint 0 is the default control endpoint and w ill always be configured in control type. ? endpoint direction configuration for bulk, interrupt and isochronous endpoints, the direction is defined with the epdir bit of the uepconx register with the following values: ? in:epdir = 1b ? out:epdir = 0b for control endpoints, the epdir bit has no effect. ? summary of endpoint configuration: do not forget to select the correct endpoint number in the uepnum register before accessing to endpoint specific registers. table 90. summary of endpoint configuration endpoint configuration epen epdir eptype uepconx disabled 0b xb xxb 0xxx xxxb control 1b xb 00b 80h bulk-in 1b 1b 10b 86h bulk-out 1b 0b 10b 82h interrupt-in 1b 1b 11b 87h interrupt-out 1b 0b 11b 83h isochronous-in 1b 1b 01b 85h isochronous-out 1b 0b 01b 81h
121 at89c5131a-l 4338e?usb?06/06 ? endpoint fifo reset before using an endpoint, its fifo will be reset. this action resets the fifo pointer to its original value, resets the byte counter of the endpoint (ubyctlx and ubycthx registers), and resets the data toggle bit (dtgl bit in uepconx). the reset of an endpoint fifo is performed by setting to 1 and resetting to 0 the corresponding bit in the ueprst register. for example, in order to reset the endpoint number 2 fifo, write 0000 0100b then 0000 0000b in the ueprst register. note that the endpoint reset doesn?t reset the bank number for ping-pong endpoints. read/write data fifo fifo mapping depending on the selected endpoint through the uepnum register, the uepdatx reg- ister allows to access the corresponding endpoint data fifo. figure 60. endpoint fifo configuration read data fifo the read access for each out endpoint is performed using the uepdatx register. after a new valid packet has been received on an endpoint, the data are stored into the fifo and the byte counter of the endpoint is updated (ubyctlx and ubycthx regis- ters). the firmware has to store the endpoint byte counter before any access to the endpoint fifo. the byte counter is not updated when reading the fifo. to read data from an endpoint, select the correct endpoint number in uepnum and read the uepdatx register. this action automatically decreases the corresponding address vector, and the next data is then available in the uepdatx register. write data fifo the write access for each in endpoint is performed using the uepdatx register. to write a byte into an in endpoint fifo, select the correct endpoint number in uep- num and write into the uepdatx register. the corresponding address vector is automatically increased, and another write can be carried out. warning 1: the byte counter is not updated. warning 2: do not write more bytes than supported by the corresponding endpoint. uepnum endpoint 0 endpoint 6 uepsta0 uepcon0 uepdat0 uepsta6 uepcon6 uepdat6 0 1 2 3 4 5 6 sfr registers uepstax uepconx uepdatx x ubycth0 ubyctl0 ubycth6 ubyctl6 ubycthx ubyctlx
122 at89c5131a-l 4338e?usb?06/06 bulk/interrupt transactions bulk and interrupt transactions are managed in the same way. bulk/interrupt out transactions in standard mode figure 61. bulk/interrupt out transactions in standard mode an endpoint will be first enabled and configured before being able to receive bulk or interrupt packets. when a valid out packet is received on an endpoint, the rxoutb0 bit is set by the usb controller. this triggers an interrupt if enabled. the firmware has to select the cor- responding endpoint, store the number of data bytes by reading the ubyctlx and ubycthx registers. if the received packet is a zlp (zero length packet), the ubyctlx and ubycthx register values are equal to 0 and no data has to be read. when all the endpoint fifo bytes have been re ad, the firmware will clear the rxoutb0 bit to allow the usb controller to accept the next out packet on this endpoint. until the rxoutb0 bit has been cleared by the firmware, the usb controller will answer a nak handshake for each out requests. if the host sends more bytes than supported by the endpoint fifo, the overflow data won?t be stored, but the usb controller will consider that the packet is valid if the crc is correct and the endpoint byte counter contains the number of bytes sent by the host. out data0 (n bytes) ack host ufi c51 endpoint fifo read byte 1 out data1 nak rxoutb0 endpoint fifo read byte 2 endpoint fifo read byte n clear rxoutb0 out data1 nak out data1 ack rxoutb0 endpoint fifo read byte 1
123 at89c5131a-l 4338e?usb?06/06 bulk/interrupt out transactions in ping-pong mode figure 62. bulk/interrupt out transactions in ping-pong mode an endpoint will be first enabled and configured before being able to receive bulk or interrupt packets. when a valid out packet is received on the endpoint bank 0, the rxoutb0 bit is set by the usb controller. this triggers an interrupt if enabled. the firmware has to select the corresponding endpoint, store the number of data bytes by reading the ubyctlx and ubycthx registers. if the received packet is a zlp (zero length packet), the ubyctlx and ubycthx register values are equal to 0 and no data has to be read. when all the endpoint fifo by tes have been read, the firmwa re will clear the rxoub0 bit to allow the usb controller to accept the next out packet on the endpoint bank 0. this action switches the endpoint bank 0 and 1. until the rxoutb0 bit has been cleared by the firmware, the usb controller will answer a nak handshake for each out requests on the bank 0 endpoint fifo. when a new valid out packet is received on the endpoint bank 1, the rxoutb1 bit is set by the usb controller. this triggers an interrupt if enabled. the firmware empties the bank 1 endpoint fifo before clearing the rxoutb1 bit. until the rxoutb1 bit has been cleared by the firmware, the usb controller will answer a nak handshake for each out requests on the bank 1 endpoint fifo. the rxoutb0 and rxoutb1 bits are alternatively set by the usb controller at each new valid packet receipt. the firmware has to clear one of these two bits after having read all the data fifo to allow a new valid packet to be stored in the corresponding bank. a nak handshake is sent by the usb controller only if the banks 0 and 1 has not been released by the firmware. if the host sends more bytes than supported by the endpoint fifo, the overflow data won?t be stored, but the usb controller will consider that the packet is valid if the crc is correct. out data0 (n bytes) ack host ufi c51 endpoint fifo bank 0 - read byte 1 rxoutb0 endpoint fifo bank 0 - read byte 2 endpoint fifo bank 0 - read byte n clear rxoutb0 out data1 (m bytes) ack rxoutb1 endpoint fifo bank 1 - read byte 1 endpoint fifo bank 1 - read byte 2 endpoint fifo bank 1 - read byte m clear rxoutb1 out data0 (p bytes) ack rxoutb0 endpoint fifo bank 0 - read byte 1 endpoint fifo bank 0 - read byte 2 endpoint fifo bank 0 - read byte p clear rxoutb0
124 at89c5131a-l 4338e?usb?06/06 bulk/interrupt in transactions in standard mode figure 63. bulk/interrupt in transactions in standard mode an endpoint will be first enabled and configured before being able to send bulk or inter- rupt packets. the firmware will fill the fifo with the data to be sent and set the txrdy bit in the uep- stax register to allow the usb controller to send the data stored in fifo at the next in request concerning this endpoint. to send a zero length packet, the firmware will set the txrdy bit without writing any data into the endpoint fifo. until the txrdy bit has been set by the firmware, the usb controller will answer a nak handshake for each in requests. to cancel the sending of this packet, the firmware has to reset the txrdy bit. the packet stored in the endpoint fifo is then cleared and a new packet can be written and sent. when the in packet has been sent and acknowledged by the host, the txcmpl bit in the uepstax register is set by the usb controller. this triggers a usb interrupt if enabled. the firmware will clear the txcmpl bit before filling the endpoint fifo with new data. the firmware will never write more bytes than supported by the endpoint fifo. all usb retry mechanisms are automatically managed by the usb controller. in data0 (n bytes) ack host ufi c51 endpoint fifo write byte 1 in nak txcmpl endpoint fifo write byte 2 endpoint fifo write byte n set txrdy clear txcmpl endpoint fifo write byte 1
125 at89c5131a-l 4338e?usb?06/06 bulk/interrupt in transactions in ping-pong mode figure 64. bulk/interrupt in transactions in ping-pong mode an endpoint will be first enabled and configured before being able to send bulk or inter- rupt packets. the firmware will fill the fifo bank 0 with the data to be sent and set the txrdy bit in the uepstax register to allow the usb controller to send the data stored in fifo at the next in request concerning the endpoint. the fifo banks are automatically switched, and the firmware can immediately write into the endpoint fifo bank 1. when the in packet concerning the bank 0 has been sent and acknowledged by the host, the txcmpl bit is set by the usb controller. this triggers a usb interrupt if enabled. the firmware will clear the txcmpl bit before filling the endpoint fifo bank 0 with new data. the fifo banks are then automatically switched. when the in packet concerning the bank 1 has been sent and acknowledged by the host, the txcmpl bit is set by the usb controller. this triggers a usb interrupt if enabled. the firmware will clear the txcmpl bit before filling the endpoint fifo bank 1 with new data. the bank switch is performed by the usb controller each time the txrdy bit is set by the firmware. until the txrdy bit has been set by the firmware for an endpoint bank, the usb controller will answer a nak handshake for each in requests concerning this bank. note that in the example above, the firmware clears the transmit complete bit (txc- mpl) before setting the transmit ready bit (txrdy). this is done in order to avoid the firmware to clear at the same time the txcmpl bit for bank 0 and the bank 1. the firmware will never write more bytes than supported by the endpoint fifo. in data0 (n bytes) ack host ufi c51 endpoint fifo bank 0 - write byte 1 in nack txcmpl endpoint fifo bank 0 - write byte 2 endpoint fifo bank 0 - write byte n set txrdy endpoint fifo bank 1 - write byte 1 endpoint fifo bank 1 - write byte 2 endpoint fifo bank 1 - write byte m set txrdy in data1 (m bytes) ack endpoint fifo bank 0 - write byte 1 endpoint fifo bank 0 - write byte 2 endpoint fifo bank 0 - write byte p set txrdy clear txcmpl in data0 (p bytes) ack txcmpl clear txcmpl endpoint fifo bank 1 - write byte 1
126 at89c5131a-l 4338e?usb?06/06 control transactions setup stage the dir bit in the uepstax register will be at 0. receiving setup packets is the same as receiving bulk out packets, except that the rxsetup bit in the uepstax register is set by the usb controller instead of the rxoutb0 bit to indicate that an out packet with a setup pid has been received on the control endpoint. when the rxsetup bit has been set, all the other bits of the uep- stax register are cleared and an interrupt is triggered if enabled. the firmware has to read the setup request stored in the control endpoint fifo before clearing the rxsetup bit to free the endpoint fifo for the next transaction. data stage: control endpoint direction the data stage management is similar to bulk management. a control endpoint is managed by the usb controller as a full-duplex endpoint: in and out. all other endpoint types are managed as half-duplex endpoint: in or out. the firmware has to specify the control endpoint direction for the data stage using the dir bit in the uepstax register. the firmware has to use the dir bit before data in in order to meet the data-toggle requirements: ? if the data stage consists of ins, the firmware has to set the dir bit in the uepstax register before writing into the fifo and sending the data by setting to 1 the txrdy bit in the uepstax register. the in transaction is complete when the txcmpl has been set by the hardware. the firmware will clear the txcmpl bit before any other transaction. ? if the data stage consists of outs, the firmware has to leave the dir bit at 0. the rxoutb0 bit is set by hardware when a new valid packet has been received on the endpoint. the firmware must read the data stored into the fifo and then clear the rxoutb0 bit to reset the fifo and to allow the next transaction. to send a stall handshake, see ?stall handshake? on page 129. status stage the dir bit in the uepstax register will be reset at 0 for in and out status stage. the status stage management is similar to bulk management. ? for a control write transaction or a no-data control transaction, the status stage consists of a in zero length packet (see ?bulk/interrupt in transactions in standard mode? on page 124). to send a stall handshake, see ?stall handshake? on page 129. ? for a control read transaction, the status stage consists of a out zero length packet (see ?bulk/interrupt out transactions in standard mode? on page 122).
127 at89c5131a-l 4338e?usb?06/06 isochronous transactions isochronous out transactions in standard mode an endpoint will be first enabled and configured before being able to receive isochro- nous packets. when a out packet is received on an endpoint, the rxoutb0 bit is set by the usb controller. this triggers an interrupt if enabled. the firmware has to select the corre- sponding endpoint, store the number of data bytes by reading the ubyctlx and ubycthx registers. if the received packet is a zlp (zero length packet), the ubyctlx and ubycthx register values are equal to 0 and no data has to be read. the stlcrc bit in the uepstax register is set by the usb controller if the packet stored in fifo has a corrupted crc. this bit is updated after each new packet receipt. when all the endpoint fifo bytes have been re ad, the firmware will clear the rxoutb0 bit to allow the usb controller to store the next out packet data into the endpoint fifo. until the rxoutb0 bit has been cleared by the firmware, the data sent by the host at each out transaction will be lost. if the rxoutb0 bit is cleared while the host is sending data, the usb controller will store only the remaining bytes into the fifo. if the host sends more bytes than supported by the endpoint fifo, the overflow data won?t be stored, but the usb controller will consider that the packet is valid if the crc is correct. isochronous out transactions in ping-pong mode an endpoint will be first enabled and configured before being able to receive isochro- nous packets. when a out packet is received on the endpoint bank 0, the rxoutb0 bit is set by the usb controller. this triggers an interrupt if enabled. the firmware has to select the cor- responding endpoint, store the number of data bytes by reading the ubyctlx and ubycthx registers. if the received packet is a zlp (zero length packet), the ubyctlx and ubycthx register values are equal to 0 and no data has to be read. the stlcrc bit in the uepstax register is set by the usb controller if the packet stored in fifo has a corrupted crc. this bit is updated after each new packet receipt. when all the endpoint fifo by tes have been read, the firmwa re will clear the rxoub0 bit to allow the usb controller to store the next out packet data into the endpoint fifo bank 0. this action switches the endpoint bank 0 and 1. until the rxoutb0 bit has been cleared by the firmware, the data sent by the host on the bank 0 endpoint fifo will be lost. if the rxoutb0 bit is cleared while the host is sending data on the endpoint bank 0, the usb controller will store only the remaining bytes into the fifo. when a new out packet is received on the endpoint bank 1, the rxoutb1 bit is set by the usb controller. this triggers an interrupt if enabled. the firmware empties the bank 1 endpoint fifo before clearing the rxoutb1 bit. until the rxoutb1 bit has been cleared by the firmware, the data sent by the host on the bank 1 endpoint fifo will be lost. the rxoutb0 and rxoutb1 bits are alternatively set by the usb controller at each new packet receipt. the firmware has to clear one of these two bits after having read all the data fifo to allow a new packet to be stored in the corresponding bank.
128 at89c5131a-l 4338e?usb?06/06 if the host sends more bytes than supported by the endpoint fifo, the overflow data won?t be stored, but the usb controller will consider that the packet is valid if the crc is correct. isochronous in transactions in standard mode an endpoint will be first enabled and configured before being able to send isochronous packets. the firmware will fill the fifo with the data to be sent and set the txrdy bit in the uep- stax register to allow the usb controller to send the data stored in fifo at the next in request concerning this endpoint. if the txrdy bit is not set when the in request occurs, nothing will be sent by the usb controller. when the in packet has been sent, the txcmpl bit in the uepstax register is set by the usb controller. this triggers a usb interrupt if enabled. the firmware will clear the txcmpl bit before filling the endpoint fifo with new data. the firmware will never write more bytes than supported by the endpoint fifo isochronous in transactions in ping-pong mode an endpoint will be first enabled and configured before being able to send isochronous packets. the firmware will fill the fifo bank 0 with the data to be sent and set the txrdy bit in the uepstax register to allow the usb controller to send the data stored in fifo at the next in request concerning the endpoint. the fifo banks are automatically switched, and the firmware can immediately write into the endpoint fifo bank 1. if the txrdy bit is not set when the in request occurs, nothing will be sent by the usb controller. when the in packet concerning the bank 0 has been sent, the txcmpl bit is set by the usb controller. this triggers a usb interrupt if enabled. the firmware will clear the txc- mpl bit before f illing the endpoint fifo bank 0 with new data. the fifo banks are then automatically switched. when the in packet concerning the bank 1 has been sent, the txcmpl bit is set by the usb controller. this triggers a usb interrupt if enabled. the firmware will clear the txc- mpl bit before fi lling the endpoint fifo b ank 1 with new data. the bank switch is performed by the usb controller each time the txrdy bit is set by the firmware. until the txrdy bit has been set by the firmware for an endpoint bank, the usb controller won?t send anything at each in requests concerning this bank. the firmware will never write more bytes than supported by the endpoint fifo.
129 at89c5131a-l 4338e?usb?06/06 miscellaneous usb reset the eorint bit in the usbint register is set by hardware when a end of reset has been detected on the usb bus. this triggers a usb interrupt if enabled. the usb con- troller is still enabled, but all the usb register s are reset by hardware. the firmware will clear the eorint bit to allow the next usb reset detection. stall handshake this function is only available for control, bulk, and interrupt endpoints. the firmware has to set the stallrq bit in the uepstax register to send a stall handshake at the next request of the host on the endpoint selected with the uepnum register. the rxsetup, txrdy, txcmpl, rxoutb0 and rxoutb1 bits must be first reset to 0. the bit stlcrc is set at 1 by the usb controller when a stall has been sent. this triggers an interrupt if enabled. the firmware will clear the stallrq and stlcrc bits after each stall sent. the stallrq bit is cleared automatically by hardware when a valid setup pid is received on a control type endpoint. important note: when a clear halt feature occurs for an endpoint, the firmware will reset this endpoint using the ueprst register in order to reset the data toggle management. start of frame detection the sofint bit in the usbint register is set when the usb controller detects a start of frame pid. this triggers an interrupt if enabled. the firmware will clear the sofint bit to allow the next start of frame detection. frame number when receiving a start of frame, the frame number is automatically stored in the ufnuml and ufnumh registers. the crcok and crcerr bits indicate if the crc of the last start of frame is valid (crcok set at 1) or corrupted (crcerr set at 1). the ufnuml and ufnumh registers are automatically updated when receiving a new start of frame. data toggle bit the data toggle bit is set by hardware when a data0 packet is received and accepted by the usb controller and cleared by hardware when a data1 packet is received and accepted by the usb controller. this bit is reset when the firmware resets the endpoint fifo using the ueprst register. for control endpoints, each setup transaction starts with a data0 and data toggling is then used as for bulk endpoints until the end of the data stage (for a control write transfer). the status stage completes the data transfer with a data1 (for a control read transfer). for isochronous endpoints, the device firmware will ignore the data-toggle.
130 at89c5131a-l 4338e?usb?06/06 suspend/resume management suspend the suspend state can be detected by the usb controller if all the clocks are enabled and if the usb controller is enabled. the bit spint is set by hardware when an idle state is detected for more than 3 ms. this triggers a usb interrupt if enabled. in order to reduce current consumption, the firmware can put the usb pad in idle mode, stop the clocks and put the c51 in idle or power-down mode. the resume detection is still active. the usb pad is put in idle mode when the firmware clear the spint bit. in order to avoid a new suspend detection 3ms later, the firmware has to disable the usb clock input using the suspclk bit in the usbcon register. the usb pad automatically exits of idle mode when a wake-up event is detected. the stop of the 48 mhz clock from the pll should be done in the following order: 1. clear suspend interrupt bit in usbint (required to allow the usb pads to enter power down mode). 2. enable usb resume interrupt. 3. disable of the 48 mhz clock input of the usb controller by setting to 1 the sus- pclk bit in the usbcon register. 4. disable the pll by clearing the pllen bit in the pllcon register. 5. make the cpu core enter power down mode by setting pdown bit in pcon. resume when the usb controller is in suspend state, the resume detection is active even if all the clocks are disabled and if the c51 is in idle or power-down mode. the wupcpu bit is set by hardware when a non-idle state occurs on the usb bus. this triggers an inter- rupt if enabled. this interrupt wakes up the cpu from its idle or power-down state and the interrupt function is then executed. the firmware will first enable the 48 mhz gener- ation and then reset to 0 the suspclk bit in the usbcon register if needed. the firmware has to clear the spint bit in the usbint register before any other usb operation in order to wake up the usb controller from its suspend mode. the usb controller is then re-activated.
131 at89c5131a-l 4338e?usb?06/06 figure 65. example of a suspend/resume management usb controller init detection of a suspend state spint set suspclk disable pll microcontroller in power-down detection of a resume state wupcpu enable pll clear suspclk clear wupcpu bit clear spint
132 at89c5131a-l 4338e?usb?06/06 upstream resume a usb device can be allowed by the host to send an upstream resume for remote wake up purpose. when the usb controller receives the set_feature request: device_remote_wakeup, the firmware will set to 1 the rmwupe bit in the usb- con register to enable this functionality. rmwupe value will be 0 in the other cases. if the device is in suspend mode, the usb controller can send an upstream resume by clearing first the spint bit in the usbint register and by setting then to 1 the sdrm- wup bit in the usbcon register. the usb controller sets to 1 the uprsm bit in the usbcon register. all clocks must be enabled first. the remote wake is sent only if the usb bus was in suspend state for at least 5 ms. when the upstream resume is com- pleted, the uprsm bit is reset to 0 by hardware. the firmware will then clear the sdrmwup bit. figure 66. example of remote wakeup management usb controller init detection of a suspend state spint set rmwupe suspend management enable clocks upstream resume sent uprsm clear spint set sdmwup clear sdrmwup set_feature: device_remote_wakeup need usb resum e uprsm = 1
133 at89c5131a-l 4338e?usb?06/06 detach simulation in order to be re-enumerated by the host, the at89c5131a-l has the possibility to sim- ulate a detach - attach of the usb bus. the v ref output voltage is between 3.0v and 3.6v. this output can be connected to the d+ pull-up as shown in figure 67. this output can be put in high-impedance when the detach bit is set to 1 in the usbcon register. maintaining this output in high imped- ance for more than 3 s will simulate the disconnection of the device. when resetting the detach bit, an attach is then simulated. figure 67. example of v ref connection figure 68. disconnect timing usb interrupt system interrupt system priorities figure 69. usb interrupt control system d- d+ d- d+ gnd v cc v ref 1.5 k usb-b connect or 1 2 3 4 at89c5131 d+ d- v ss v il v ihz (min) device disconnected disconnect detected > = 2,5 s eusb ie1.6 ea ie0.7 usb controller iph/l interrupt enable lowest priority interrupts priority enable 00 01 10 11 d+ d-
134 at89c5131a-l 4338e?usb?06/06 table 91. priority levels usb interrupt control system as shown in figure 70, many events can produce a usb interrupt: ? txcmpl: transmitted in data (see table 98 on page 141). this bit is set by hardware when the host accept a in packet. ? rxoutb0: received out data bank 0 (see table 98 on page 141). this bit is set by hardware when an out packet is accepted by the endpoint and stored in bank 0. ? rxoutb1: received out data bank 1 (only for ping-pong endpoints) (see table 98 on page 141). this bit is set by hardware when an out packet is accepted by the endpoint and stored in bank 1. ? rxsetup: received setup (see table 98 on page 141). this bit is set by hardware when an setup packet is accepted by the endpoint. ? stlcrc: stalled (only for control, bulk and interrupt endpoints) (see table 98 on page 141). this bit is set by hardware when a stall handshake has been sent as requested by stallrq, and is re set by hardware when a setup packet is received. ? sofint: start of frame interrupt (see ?usbien register usbien (s:beh) usb global interrupt enable register? on page 13 8.). this bit is set by hardware when a usb start of frame packet has been received. ? wupcpu: wake-up cpu interrupt (see ?usbien register usbien (s:beh) usb global interrupt enable register? on page 13 8.). this bit is set by hardware when a usb resume is detected on the usb bus, after a suspend state. ? spint: suspend interrupt (see ?usbien register usbien (s:beh) usb global interrupt enable register? on page 138.). this bit is set by hardware when a usb suspend is detected on the usb bus. iphusb iplusb usb priority level 0 0 0 lowest 011 102 113highest
135 at89c5131a-l 4338e?usb?06/06 figure 70. usb interrupt control block diagram txcmp uepstax.0 rxoutb0 uepstax.1 rxsetup uepstax.2 stlcrc uepstax.3 epxie uepien.x epxint uepint.x sofint usbint.3 esofint usbien.3 spint usbint.0 espint usbien.0 eusb ie1.6 endpoint x (x = 0..6) eorint usbint.4 wupcpu usbint.5 ewupcpu usbien.5 rxoutb1 uepstax.6 eeorint usbien.4
136 at89c5131a-l 4338e?usb?06/06 usb registers table 92. usbcon register usbcon (s:bch) usb global control register reset value = 00h 76543210 usbe suspclk sdrmwup detach uprsm rmwupe confg fadden bit number bit mnemonic description 7 usbe usb enable set this bit to enable the usb controller. clear this bit to disable and reset the usb controller, to disable the usb transceiver an to disable the usb controller clock inputs. 6 suspclk suspend usb clock set this bit to disable the 48 mhz clock input (resume detection is still active). clear this bit to enable the 48 mhz clock input. 5 sdrmwup send remote wake up set this bit to force an external interrupt on the usb controller for remote wake up purpose. an upstream resume is send only if the bit rmwupe is set, all usb clocks are enabled and the usb bus was in suspend state for at least 5 ms. see uprsm below. this bit is cleared by software. 4 detach detach command set this bit to simulate a detach on the usb line. the v ref pin is then in a floating state. clear this bit to maintain v ref at high level. 3 uprsm upstream resume (read only) this bit is set by hardware when sdrmwup has been set and if rmwupe is enabled. this bit is cleared by hardware after the upstream resume has been sent. 2rmwupe remote wake-up enable set this bit to enabled request an upstream resume signaling to the host. clear this bit otherwise. note: do not set this bit if the host has not set the device_remote_wakeup feature for the device. 1confg configured this bit will be set by the device firmware after a set_configuration request with a non-zero value has been correctly processed. it will be cleared by the device firmware when a set_configuration request with a zero value is received. it is cleared by hardware on hardware reset or when an usb reset is detected on the bus (se0 state for at least 32 full speed bit times: typically 2.7 s). 0 fadden function address enable this bit will be set by the device firmware after a successful status phase of a set_address transaction. it will not be cleared afterwards by the device firmware. it is cleared by hardware on hardware reset or when an usb reset is received (see above). when this bit is cleared, the default function address is used (0).
137 at89c5131a-l 4338e?usb?06/06 table 93. usbint register usbint (s:bdh) usb global interrupt register reset value = 00h 76543210 - - wupcpu eorint sofint - - spint bit number bit mnemonic description 7-6 - reserved the value read from these bits is always 0. do not set these bits. 5 wupcpu wake up cpu interrupt this bit is set by hardware when the usb controller is in suspend state and is re-activated by a non-idle signal from usb line (not by an upstream resume). this triggers a usb interrupt when ewupcpu is set in table 94 on page 138. when receiving this interrupt, user has to enable all usb clock inputs. this bit will be cleared by software (usb clocks must be enabled before). 4eorint end of reset interrupt this bit is set by hardware when a end of reset has been detected by the usb controller. this triggers a usb interrupt when eeorint is set (see figure 94 on page 138). this bit will be cleared by software. 3sofint start of frame interrupt this bit is set by hardware when an usb start of frame pid (sof) has been detected. this triggers a usb interrupt when esofint is set (see table 94 on page 138). this bit will be cleared by software. 2- reserved the value read from this bit is always 0. do not set this bit. 1- reserved the value read from this bit is always 0. do not set this bit. 0 spint suspend interrupt this bit is set by hardware when a usb suspend (idle bus for three frame periods: a j state for 3 ms) is detected. this triggers a usb interrupt when espint is set in see table 94 on page 138. this bit will be cleared by software before any other usb operation to re- activate the macro.
138 at89c5131a-l 4338e?usb?06/06 table 94. usbien register usbien (s:beh) usb global interrupt enable register reset value = 10h table 95. usbaddr register usbaddr (s:c6h) usb address register reset value = 80h 76543210 - - ewupcpu eeorint esofint - - espint bit number bit mnemonic description 7-6 - reserved the value read from these bits is always 0. do not set these bits. 5ewupcpu enable wake up cpu interrupt set this bit to enable wake up cpu interrupt. (see ?usbien register usbien (s:beh) usb global interrupt enable register? on page 138.) clear this bit to disable wake up cpu interrupt. 4eeofint enable end of reset interrupt set this bit to enable end of reset interrupt. (see ?usbien register usbien (s:beh) usb global interrupt enable register? on page 138.). this bit is set after reset. clear this bit to disable end of reset interrupt. 3esofint enable sof interrupt set this bit to enable sof interrupt. (see ?usbien register usbien (s:beh) usb global interrupt enable register? on page 138.). clear this bit to disable sof interrupt. 2- reserved the value read from these bits is always 0. do not set these bits. 1- 0 espint enable suspend interrupt set this bit to enable suspend interrupts (see the ?usbien register usbien (s:beh) usb global interrupt enable register? on page 138). clear this bit to disable suspend interrupts. 76543210 fen uadd6 uadd5 uadd4 uadd3 uadd2 uadd1 uadd0 bit number bit mnemonic description 7fen function enable set this bit to enable the address filtering function. cleared this bit to disable the function. 6-0 uadd[6:0] usb address this field contains the default address (0) after power-up or usb bus reset. it will be written with the value set by a set_address request received by the device firmware.
139 at89c5131a-l 4338e?usb?06/06 table 96. uepnum register uepnum (s:c7h) usb endpoint number reset value = 00h 76543210 - - - - epnum3 epnum2 epnum1 epnum0 bit number bit mnemonic description 7-4 - reserved the value read from these bits is always 0. do not set these bits. 3-0 epnum[3:0] endpoint number set this field with the number of the endpoint which will be accessed when reading or writing to, uepdatx register uepdatx (s:cfh) usb fifo data endpoint x (x = epnum set in uepnum register uepnum (s:c7h) usb endpoint number), ubyctlx register ubyctlx (s:e2h) usb byte count low register x (x = epnum set in uepnum register uepnum (s:c7h) usb endpoint number), ubycthx register ubycthx (s:e3h) usb byte count high register x (x = epnum set in uepnum register uepnum (s:c7h) usb endpoint number) or uepconx register uepconx (s:d4h) usb endpoint x control register. this value can be 0, 1, 2, 3, 4, 5 or 6.
140 at89c5131a-l 4338e?usb?06/06 table 97. uepconx register uepconx (s:d4h) usb endpoint x control register note: 1. (x = epnum set in uepnum register uepnum (s:c7h) usb endpoint number) reset value = 80h when uepnum = 0 (default control endpoint) reset value = 00h otherwise for all other endpoints 76543210 epen - - - dtgl epdir eptype1 eptype0 bit number bit mnemonic description 7 epen endpoint enable set this bit to enable the endpoint according to the device configuration. endpoint 0 will always be enabled after a hardware or usb bus reset and participate in the device configuration. clear this bit to disable the endpoint according to the device configuration. 6- reserved the value read from this bit is always 0. do not set this bit. 5- reserved the value read from this bit is always 0. do not set this bit. 4- reserved the value read from this bit is always 0. do not set this bit. 3dtgl data toggle (read-only) this bit is set by hardware when a valid data0 packet is received and accepted. this bit is cleared by hardware when a valid data1 packet is received and accepted. 2epdir endpoint direction set this bit to configure in direction for bulk, interrupt and isochronous endpoints. clear this bit to configure out direction for bulk, interrupt and isochronous endpoints. this bit has no effect for control endpoints. 1-0 eptype[1:0] endpoint type set this field according to the endpoint configuration (endpoint 0 will always be configured as control): 00control endpoint 01isochronous endpoint 10bulk endpoint 11interrupt endpoint
141 at89c5131a-l 4338e?usb?06/06 reset value = 00h table 98. uepstax (s:ceh) usb e ndpoint x status register 76543210 dir rxoutb1 stallrq txrdy stl/crc rxsetup rxoutb0 txcmp bit number bit mnemonic description 7dir control endpoint direction this bit is used only if the endpoint is configured in the control type (seesection ?uepconx register uepconx (s:d4h) usb endpoint x control register?). this bit determines the control data and status direction. the device firmware will set this bit only for the in data stage, before any other usb operation. otherwise, the device firmware will clear this bit. 6rxoutb1 received out data bank 1 for endpoints 4, 5 and 6 (ping-pong mode) this bit is set by hardware after a new packet has been stored in the endpoint fifo data bank 1 (only in ping-pong mode). then, the endpoint interrupt is triggered if enabled (see?uepint register uepint (s:f8h read-only) usb endpoint interrupt register? on page 145) and all the following out packets to the endpoint bank 1 are rejected (nak?ed) until this bit has been cleared, excepted for isochronous endpoints. this bit will be cleared by the device firmware after reading the out data from the endpoint fifo. 5stallrq stall handshake request set this bit to request a stall answer to the host for the next handshake.clear this bit otherwise. for control endpoints: cleared by hardware when a valid setup pid is received. 4 txrdy tx packet ready set this bit after a packet has been written into the endpoint fifo for in data transfers. data will be written into the endpoint fifo only after this bit has been cleared. set this bit without writing data to the endpoint fifo to send a zero length packet. this bit is cleared by hardware, as soon as the packet has been sent for isochronous endpoints, or after the host has acknowledged the packet for control, bulk and interrupt endpoints. when this bit is cleared, the endpoint interrupt is triggered if enabled (see?uepint register uepint (s:f8h read-only) usb endpoint interrupt register? on page 145). 3 stlcrc stall sent/crc error flag - for control, bulk and interrupt endpoints: this bit is set by hardware after a stall handshake has been sent as requested by stallrq. then, the endpoint interrupt is triggered if enabled (see?uepint register uepint (s:f8h read-only) usb endpoint interrupt register? on page 145) it will be cleared by the device firmware. - for isochronous endpoints (read-only) : this bit is set by hardware if the last received data is corrupted (crc error on data). this bit is updated by hardware when a new data is received. 2 rxsetup received setup this bit is set by hardware when a valid setup packet has been received from the host. then, all the other bits of the register are cleared by hardware and the endpoint interrupt is triggered if enabled (see?uepint register uepint (s:f8h read-only) usb endpoint interrupt register? on page 145). it will be cleared by the device firmware after reading the setup data from the endpoint fifo. 1rxoutb0 received out data bank 0 (see also rxoutb1 bit for ping-pong endpoints) this bit is set by hardware after a new packet has been stored in the endpoint fifo data bank 0. then, the endpoint interrupt is triggered if enabled (see?uepint register uepint (s:f8h read-only) usb endpoint interrupt register? on page 145) and all the following out packets to the endpoint bank 0 are rejected (nak?ed) until this bit has been cleared, excepted for isochronous endpoints. however, for control endpoints, an early setup transaction may overwrite the content of the endpoint fifo, even if its data packet is received while this bit is set. this bit will be cleared by the device firmware after reading the out data from the endpoint fifo. 0txcmpl transmitted in data complete this bit is set by hardware after an in packet has been transmitted for isochronous endpoints and after it has been accepted (ack?ed) by the host for control, bulk and interrupt endpoints. then, the endpoint interrupt is triggered if enabled (see?uepint register uepint (s:f8h read-only) usb endpoint interrupt register? on page 145). this bit will be cleared by the device firmware before setting txrdy.
142 at89c5131a-l 4338e?usb?06/06 table 99. uepdatx register uepdatx (s:cfh) usb fifo data endpoint x (x = epnum set in uepnum register uepnum (s:c7h) usb endpoint number) reset value = xxh table 100. ubyctlx register ubyctlx (s:e2h) usb byte count low register x (x = epnum set in uepnum register uepnum (s:c7h) usb endpoint number) reset value = 00h 76543210 fdat7 fdat6 fdat5 fdat4 fdat3 fdat2 fdat1 fdat0 bit number bit mnemonic description 7 - 0 fdat [7:0] endpoint x fifo data data byte to be written to fifo or data byte to be read from the fifo, for the endpoint x (see epnum). 76543210 byct7 byct6 byct5 byct4 byct3 byct2 byct1 byct0 bit number bit mnemonic description 7 - 0 byct[7:0] byte count lsb least significant byte of the byte count of a received data packet. the most significant part is provided by the ubycthx register ubycthx (s:e3h) usb byte count high register x (x = epnum set in uepnum register uepnum (s:c7h) usb endpoint number) (see figure 100 on page 142). this byte count is equal to the number of data bytes received after the data pid.
143 at89c5131a-l 4338e?usb?06/06 table 101. ubycthx register ubycthx (s:e3h) usb byte count high register x (x = epnum set in uepnum register uepnum (s:c7h) usb endpoint number) reset value = 00h 76543210 ------byct9byct8 bit number bit mnemonic description 7-2 - reserved the value read from these bits is always 0. do not set these bits. 2-0 byct[10:8] byte count msb most significant byte of the byte count of a received data packet. the least significant part is provided by ubyctlx register ubyctlx (s:e2h) usb byte count low register x (x = epnum set in uepnum register uepnum (s:c7h) usb endpoint number) (see figure 100 on page 142).
144 at89c5131a-l 4338e?usb?06/06 table 102. ueprst register ueprst (s:d5h) usb endpoint fifo reset register reset value = 00h 76543210 - ep6rst ep5rst ep4rst ep3rst ep2rst ep1rst ep0rst bit number bit mnemonic description 7- reserved the value read from this bit is always 0. do not set this bit. 6ep6rst endpoint 6 fifo reset set this bit and reset the endpoint fifo prior to any other operation, upon hardware reset or when an usb bus reset has been received. then, clear this bit to complete the reset operation and start using the fifo. 5ep5rst endpoint 5 fifo reset set this bit and reset the endpoint fifo prior to any other operation, upon hardware reset or when an usb bus reset has been received. then, clear this bit to complete the reset operation and start using the fifo. 4ep4rst endpoint 4 fifo reset set this bit and reset the endpoint fifo prior to any other operation, upon hardware reset or when an usb bus reset has been received. then, clear this bit to complete the reset operation and start using the fifo. 3ep3rst endpoint 3 fifo reset set this bit and reset the endpoint fifo prior to any other operation, upon hardware reset or when an usb bus reset has been received. then, clear this bit to complete the reset operation and start using the fifo. 2ep2rst endpoint 2 fifo reset set this bit and reset the endpoint fifo prior to any other operation, upon hardware reset or when an usb bus reset has been received. then, clear this bit to complete the reset operation and start using the fifo. 1ep1rst endpoint 1 fifo reset set this bit and reset the endpoint fifo prior to any other operation, upon hardware reset or when an usb bus reset has been received. then, clear this bit to complete the reset operation and start using the fifo. 0ep0rst endpoint 0 fifo reset set this bit and reset the endpoint fifo prior to any other operation, upon hardware reset or when an usb bus reset has been received. then, clear this bit to complete the reset operation and start using the fifo.
145 at89c5131a-l 4338e?usb?06/06 table 103. uepint register uepint (s:f8h read-only) usb endpoint interrupt register reset value = 00h 76543210 - ep6int ep5int ep4int ep3int ep2int ep1int ep0int bit number bit mnemonic description 7- reserved the value read from this bit is always 0. do not set this bit. 6 ep6int endpoint 6 interrupt this bit is set by hardware when an endpoint interrupt source has been detected on the endpoint 6. the endpoint interrupt sources are in the uepstax register and can be: txcmp, rxoutb0, rxoutb1, rxsetup or stlcrc. a usb interrupt is triggered when the ep6ie bit in the uepien register is set. this bit is cleared by hardware when all the endpoint interrupt sources are cleared 5 ep5int endpoint 5 interrupt this bit is set by hardware when an endpoint interrupt source has been detected on the endpoint 5. the endpoint interrupt sources are in the uepstax register and can be: txcmp, rxoutb0, rxoutb1, rxsetup or stlcrc. a usb interrupt is triggered when the ep5ie bit in the uepien register is set. this bit is cleared by hardware when all the endpoint interrupt sources are cleared 4 ep4int endpoint 4 interrupt this bit is set by hardware when an endpoint interrupt source has been detected on the endpoint 4. the endpoint interrupt sources are in the uepstax register and can be: txcmp, rxoutb0, rxoutb1, rxsetup or stlcrc. a usb interrupt is triggered when the ep4ie bit in the uepien register is set. this bit is cleared by hardware when all the endpoint interrupt sources are cleared 3 ep3int endpoint 3 interrupt this bit is set by hardware when an endpoint interrupt source has been detected on the endpoint 3. the endpoint interrupt sources are in the uepstax register and can be: txcmp, rxoutb0, rxoutb1, rxsetup or stlcrc. a usb interrupt is triggered when the ep3ie bit in the uepien register is set. this bit is cleared by hardware when all the endpoint interrupt sources are cleared 2 ep2int endpoint 2 interrupt this bit is set by hardware when an endpoint interrupt source has been detected on the endpoint 2. the endpoint interrupt sources are in the uepstax register and can be: txcmp, rxoutb0, rxoutb1, rxsetup or stlcrc. a usb interrupt is triggered when the ep2ie bit in the uepien register is set. this bit is cleared by hardware when all the endpoint interrupt sources are cleared 1 ep1int endpoint 1 interrupt this bit is set by hardware when an endpoint interrupt source has been detected on the endpoint 1. the endpoint interrupt sources are in the uepstax register and can be: txcmp, rxoutb0, rxoutb1, rxsetup or stlcrc. a usb interrupt is triggered when the ep1ie bit in the uepien register is set. this bit is cleared by hardware when all the endpoint interrupt sources are cleared 0 ep0int endpoint 0 interrupt this bit is set by hardware when an endpoint interrupt source has been detected on the endpoint 0. the endpoint interrupt sources are in the uepstax register and can be: txcmp, rxoutb0, rxoutb1, rxsetup or stlcrc. a usb interrupt is triggered when the ep0ie bit in the uepien register is set. this bit is cleared by hardware when all the endpoint interrupt sources are cleared
146 at89c5131a-l 4338e?usb?06/06 table 104. uepien register uepien (s:c2h) usb endpoint interrupt enable register reset value = 00h 76543210 - ep6inte ep5inte ep4inte ep3inte ep2inte ep1inte ep0inte bit number bit mnemonic description 7- reserved the value read from this bit is always 0. do not set this bit. 6 ep6inte endpoint 6 interrupt enable set this bit to enable the interrupts for this endpoint. clear this bit to disable the interrupts for this endpoint. 5 ep5inte endpoint 5 interrupt enable set this bit to enable the interrupts for this endpoint. clear this bit to disable the interrupts for this endpoint. 4 ep4inte endpoint 4 interrupt enable set this bit to enable the interrupts for this endpoint. clear this bit to disable the interrupts for this endpoint. 3 ep3inte endpoint 3 interrupt enable set this bit to enable the interrupts for this endpoint. clear this bit to disable the interrupts for this endpoint. 2 ep2inte endpoint 2 interrupt enable set this bit to enable the interrupts for this endpoint. clear this bit to disable the interrupts for this endpoint. 1 ep1inte endpoint 1 interrupt enable set this bit to enable the interrupts for this endpoint. clear this bit to disable the interrupts for this endpoint. 0 ep0inte endpoint 0 interrupt enable set this bit to enable the interrupts for this endpoint. clear this bit to disable the interrupts for this endpoint.
147 at89c5131a-l 4338e?usb?06/06 table 105. ufnumh register ufnumh (s:bbh, read-only) usb frame number high register reset value = 00h table 106. ufnuml register ufnuml (s:bah, read-only) usb frame number low register reset value = 00h 76543210 - - crcok crcerr - fnum10 fnum9 fnum8 bit number bit mnemonic description 5 crcok frame number crc ok this bit is set by hardware when a new frame number in start of frame packet is received without crc error. this bit is updated after every start of frame packet receipt. important note: the start of frame interrupt is generated just after the pid receipt. 4 crcerr frame number crc error this bit is set by hardware when a corrupted frame number in start of frame packet is received. this bit is updated after every start of frame packet receipt. important note: the start of frame interrupt is generated just after the pid receipt. 3- reserved the value read from this bit is always 0. do not set this bit. 2-0 fnum[10:8] frame number fnum[10:8] are the upper 3 bits of the 11-bit frame number (see the ?ufnuml register ufnuml (s:bah, read-only) usb frame number low register? on page 147). it is provided in the last received sof packet (see sofint in the ?usbien register usbien (s:beh) usb global interrupt enable register? on page 138). fnum is updated if a corrupted sof is received. 76543210 fnum7 fnum6 fnum5 fnum4 fnum3 fnum2 fnum1 fnum0 bit number bit mnemonic description 7 - 0 fnum[7:0] frame number fnum[7:0] are the lower 8 bits of the 11-bit frame number (see ?ufnumh register ufnumh (s:bbh, read-only) usb frame number high register? on page 147.).
148 at89c5131a-l 4338e?usb?06/06 reset introduction the reset sources are: power management, hardware watchdog, pca watchdog and reset input. figure 71. reset schematic reset input the reset input can be used to force a reset pulse longer than the internal reset con- trolled by the power monitor. rst input has a pull-up resistor allowing power-on reset by simply connecting an external capacitor to v ss as shown in figure 72. resistor value and input characteristics are discussed in the section ?dc characteristics? of the at89c5131a-l datasheet. figure 72. reset circuitry and power-on reset power monitor hardware watchdog pca watchdog rst internal reset rst r rst vcc to internal reset rst vss + b. power-on rese t a. rst input circuitry
149 at89c5131a-l 4338e?usb?06/06 reset output as detailed in section ?hardware watchdog timer?, page 155, the wdt generates a 96- clock period pulse on the rst pin. in order to properly propagate this pulse to the rest of the application in case of external capacitor or power-supply supervisor circuit, a 1 k resistor must be added as shown figure 73. figure 73. recommended reset output schematic rst vss + vss vdd rst 1k to other on-board circuitry at89c5131a-m
150 at89c5131a-l 4338e?usb?06/06 power monitor the por/pfd function monitors the internal power-supply of the cpu core memories and the peripherals, and if needed, suspends t heir activity when the internal power sup- ply falls below a safety threshold. this is achieved by applying an internal reset to them. by generating the reset the power monitor insures a correct start up when at89c5131 is powered up. description in order to startup and maintain the microcontroller in correct operating mode, v cc has to be stabilized in the v cc operating range and the oscillator has to be stabilized with a nominal amplitude compatible with logic level vih/vil. these parameters are controlled during the three phases: power-up, normal operation and power going down. see figure 74. figure 74. power monitor block diagram note: 1. once xtal1 high and low levels reach above and below vih/vil. a 1024 clock period delay will extend the reset coming from the power fail detect. if the power falls below the power fail detect threshold level, the reset will be applied immediately. the voltage regulator generates a regulated internal supply for the cpu core the mem- ories and the peripherals. spikes on the external vcc are smoothed by the voltage regulator. vcc power on reset power fail detect voltage regulator xtal1 (1) cpu core memories peripherals regulated supply rst pin hardware watchdog pca watchdog internal reset
151 at89c5131a-l 4338e?usb?06/06 the power fail detect monitor the supply generated by the voltage regulator and gener- ate a reset if this supply falls below a safety threshold as illustrated in the figure 75 below. figure 75. power fail detect when the power is applied, the power monitor immediately asserts a reset. once the internal supply after the voltage regulator reach a safety level, the power monitor then looks at the xtal clock input. the internal reset will remain asserted until the xtal1 lev- els are above and below vih and vil. further more. an internal counter will count 1024 clock periods before the reset is de-asserted. if the internal power supply falls below a safety level, a reset is immediately asserted. . vcc t reset vcc
152 at89c5131a-l 4338e?usb?06/06 power management idle mode an instruction that sets pcon.0 indicates that it is the last instruction to be executed before going into the idle mode. in the idle mode, the internal clock signal is gated off to the cpu, but not to the interrupt, timer, and serial port functions. the cpu status is preserved in its entirety: the stack pointer, program counter, program status word, accumulator and all other registers maintain their data during idle. the port pins hold the logical states they had at the time idle was activated. ale and psen hold at logic high level. there are two ways to terminate the idle mode. activation of any enabled interrupt will cause pcon.0 to be cleared by hardware, terminating the idle mode. the interrupt will be serviced, and following reti the next instruction to be executed will be the one fol- lowing the instruction that put the device into idle. the flag bits gf0 and gf1 can be used to give an indication if an interrupt occurred dur- ing normal operation or during an idle. for example, an instruction that activates idle can also set one or both flag bits. when idle is terminated by an interrupt, the interrupt service routine can examine the flag bits. the other way of terminating the idle mode is with a hardware reset. since the clock oscillator is still running, the hardware reset needs to be held active for only two machine cycles (24 oscillator periods) to complete the reset. power-down mode to save maximum power, a power-down mode can be invoked by software (refer to table 13, pcon register). in power-down mode, the oscillator is stopped and the instruction that invoked power- down mode is the last instruction executed. the internal ram and sfrs retain their value until the power-down mode is terminated. v cc can be lowered to save further power. either a hardware reset or an external interrupt can cause an exit from power- down. to properly terminate power-down, the reset or external interrupt should not be executed before v cc is restored to its normal operating level and must be held active long enough for the oscillator to restart and stabilize. only: ? external interrupt int0 , ? external interrupt int1 , ? keyboard interrupt and ? usb interrupt are useful to exit from power-down. for that, interrupt must be enabled and configured as level or edge sensitive interrupt input. when keyboard interrupt occurs after a power down mode, 1024 clocks are necessary to ex it to power-down mode and enter in oper- ating mode. holding the pin low restarts the oscillator but bringing the pin high completes the exit as detailed in figure 76. when both interrupts are enabled, the oscillator restarts as soon as one of the two inputs is held low and power-down exit will be completed when the first input is released. in this case, the higher priority interrupt service routine is executed. once the interrupt is serviced, the next instruction to be executed after reti will be the one following the instruction that put at89c5131a-l into power-down mode.
153 at89c5131a-l 4338e?usb?06/06 figure 76. power-down exit waveform exit from power-down by reset redefines all the sfrs, exit from power-down by external interrupt does no affect the sfrs. exit from power-down by either reset or external interrupt does not affect the internal ram content. note: if idle mode is activated with power-down mode (idl and pd bits set), the exit sequence is unchanged, when execution is vectored to interrupt, pd and idl bits are cleared and idle mode is not entered. this table shows the state of ports during idle and power-down modes. note: 1. port 0 can force a 0 level. a ?one? will leave port floating. int1 int0 xtal power-down phase oscillator restart phase active phase active phase table 107. state of ports mode program memory ale psen port0 port1 port2 port3 porti2 idle internal 1 1 port data (1) port data port data port data port data idle external 1 1 floating port data address port data port data power-down internal 0 0 port data (1) port data port data port data port data power-down external 0 0 floating port data port data port data port data
154 at89c5131a-l 4338e?usb?06/06 registers table 108. pcon register pcon (s:87h) power control register reset value = 10h 76543210 smod1 smod0 - pof gf1 gf0 pd idl bit number bit mnemonic description 7smod1 serial port mode bit 1 set to select double baud rate in mode 1, 2 or 3. 6smod0 serial port mode bit 0 set to select fe bit in scon register. clear to select sm0 bit in scon register 5- reserved the value read from this bit is always 0. do not set this bit. 4pof power-off flag set by hardware when v cc rises from 0 to its nominal voltage. can also be set by software. clear to recognize next reset type. 3gf1 general-purpose flag 1 set by software for general-purpose usage. cleared by software for general-purpose usage. 2gf0 general-purpose flag 0 set by software for general-purpose usage. cleared by software for general-purpose usage. 1pd power-down mode bit set this bit to enter in power-down mode. cleared by hardware when reset occurs. 0idl idle mode bit set this bit to enter in idle mode. cleared by hardware when interrupt or reset occurs.
155 at89c5131a-l 4338e?usb?06/06 hardware watchdog timer the wdt is intended as a recovery method in situations where the cpu may be sub- jected to software upset. the wdt consists of a 14-bit counter and the watchdog timer reset (wdtrst) sfr. the wdt is by default disabled from exiting reset. to enable the wdt, user must write 01eh and 0e1h in sequence to the wdtrst, sfr location 0a6h. when wdt is enabled, it will increment every machine cycle while the oscillator is running and there is no way to disable the wdt except through reset (either hardware reset or wdt overflow reset). when wdt over flows, it will drive an output reset low pulse at the rst -pin. using the wdt to enable the wdt, user must write 01eh and 0e1h in sequence to the wdtrst, sfr location 0a6h. when wdt is enabled, the user needs to service it by writing to 01eh and 0e1h to wdtrst to avoid wdt overfl ow. the 14-bit counter overflows when it reaches 16383 (3fffh) and this will reset t he device. when wdt is enabled, it will increment every machine cycle while the oscillator is running. this means the user must reset the wdt at least every 16383 machine cycle. to reset the wdt the user must write 01eh and 0e1h to wdtrst. wdtrst is a write only register. the wdt counter cannot be read or written. when wdt overflows, it will generate an output reset pulse at the rst -pin. the reset pulse duration is 96 x t clk periph , where t clk periph = 1/f clk periph . to make the best use of the wdt, it should be serviced in those sections of code that will periodically be executed within the time required to prevent a wdt reset. to have a more powerful wdt, a 2 7 counter has been added to extend the time-out capability, ranking from 16 ms to 2s at f osca = 12 mhz. to manage this feature, refer to wdtprg register description, table 110. table 109. wdtrst register wdtrst - watchdog reset register (0a6h) reset value = xxxx xxxxb write only, this sfr is used to reset/enable the wdt by writing 01eh then 0e1h in sequence. 76543210 --------
156 at89c5131a-l 4338e?usb?06/06 table 110. wdtprg register wdtprg - watchdog timer out register (0a7h) reset value = xxxx x000 wdt during power-down and idle in power-down mode the oscillator stops, which means the wdt also stops. while in power-down mode the user does not need to service the wdt. there are 2 methods of exiting power-down mode: by a hardware reset or via a level activated external interrupt which is enabled prior to entering power-down mode. when power-down is exited with hardware reset, servicing the wdt should occur as it normally should whenever the at89c5131a-l is reset. exiting power-down with an interrupt is significantly different. the interrupt is held low long enough for the oscillator to stabilize. when the interrupt is brought high, the interrupt is serviced. to prevent the wdt from resetting the device while the interrupt pin is held low, the wdt is not started until the interrupt is pulled high. it is suggested that the wdt be reset during the interrupt service routine. to ensure that the wdt does not overflow within a few states of exiting of power-down, it is better to reset the wdt just before entering power-down. in the idle mode, the oscillator cont inues to run. to prevent the wdt from resetting the at89c5131a-l while in idle mode, the user should always set up a timer that will peri- odically exit idle, service the wdt, and re-enter idle mode. 7 6 5 4 3 2 1 0 - - - - - s2 s1 s0 bit number bit mnemonic description 7- reserved the value read from this bit is undetermined. do not try to set this bit. 6- 5- 4- 3- 2 s2 wdt time-out select bit 2 1 s1 wdt time-out select bit 1 0 s0 wdt time-out select bit 0 s2 s1 s0 selected time-out 00016384x2^(214 - 1) machine cycles, 16.3 ms at fosc = 12 mhz 00116384x2^(215 - 1) machine cycles, 32.7 ms at fosc = 12 mhz 01016384x2^(216 - 1) machine cycles, 65.5 ms at fosc = 12 mhz 01116384x2^(217 - 1) machine cycles, 131 ms at fosc = 12 mhz 10016384x2^(218 - 1) machine cycles, 262 ms at fosc = 12 mhz 10116384x2^(219 - 1) machine cycles, 542 ms at fosc = 12 mhz 11016384x2^(220 - 1) machine cycles, 1.05 s at fosc = 12 mhz 11116384x2^(221 - 1) machine cycles, 2.09 s at fosc = 12 mhz 16384x2^s machine cycles
157 at89c5131a-l 4338e?usb?06/06 once mode (on chip emulation) the once mode facilitates testing and debugging of systems using at89c5131a-l without removing the circuit from the board. the once mode is invoked by driving cer- tain pins of the at89c5131a-l; the following sequence must be exercised: ? pull ale low while the device is in reset (rst high) and psen is high. ? hold ale low as rst is deactivated. while the at89c5131a-l is in once mode, an emulator or test cpu can be used to drive the circuit table 111 shows the status of the port pins during once mode. normal operation is restored when normal reset is applied. table 111. external pin status during once mode ale psen port 0 port 1 port 2 port 3 port i2 xtal1/2 weak pull-up weak pull-up float weak pull-up weak pull-up weak pull-up float active
158 at89c5131a-l 4338e?usb?06/06 reduced emi mode the ale signal is used to demultiplex address and data buses on port 0 when used with external program or data memory. nevertheless, during internal code execution, ale signal is still generated. in order to reduce emi, ale signal can be disabled by setting ao bit. the ao bit is located in auxr register at bit location 0. as soon as ao is set, ale is no longer output but remains active during movx and movc instructions and external fetches. during ale disabling, ale pin is weakly pulled high. table 112. auxr register auxr - auxiliary register (8eh) reset value = 0x0x 1100b not bit addressable 76543210 dpu - m0 - xrs1 xrs0 extram ao bit number bit mnemonic description 7dpu disable weak pull up cleared to enabled weak pull up on standard ports set to disable weak pull up on standard ports 6- reserved the value read from this bit is indeterminate. do not set this bit. 5m0 pulse length cleared to stretch movx control: the rd and the wr pulse length is 6 clock periods (default). set to stretch movx control: the rd and the wr pulse length is 30 clock periods. 4- reserved the value read from this bit is indeterminate. do not set this bit. 3xrs1 eram size xrs1 xrs0 eram size 0 0 256 bytes 0 1 512 bytes 1 0 768 bytes 1 1 1024 bytes (default) 2xrs0 1extram extram bit cleared to access internal eram using movx at ri at dptr. set to access external memory. 0ao ale output bit cleared, ale is emitted at a constant rate of 1/6 the oscillator frequency (or 1/3 if x2 mode is used) (default). set , ale is active only during a movx or movc instruction is used.
159 at89c5131a-l 4338e?usb?06/06 electrical characteristics absolute maximum ratings dc parameters t a = -40 c to +85 c; v ss = 0v; v cc = 3.3v 10%; f = 0 to 40 mhz ambient temperature under bias: i = industrial ........................................................-40 c to 85 c storage temperature .................................... -65 c to + 150 c voltage on v cc from v ss ......................................-0.5v to + 6v voltage on any pin from v ss .....................-0.5v to v cc + 0.2v note: stresses at or above those listed under ?absolute maximum ratings? may cause permanent damage to the device. this is a stress rating only and functional operation of the device at these or any other condi- tions above those indicated in the operational sections of this specification is not implied. exposure to absolute maximum rating conditions may affect device reliability. symbol parameter min typ (5) max unit test conditions v il input low voltage -0.5 0.2vcc - 0.1 v v ih input high voltage except xtal1, rst 0.2 v cc + 0.9 v cc + 0.5 v v ih1 input high voltage, xtal1, rst 0.7 v cc v cc + 0.5 v v ol output low voltage, ports 1, 2, 3 and 4 (6) 0.3 0.45 1.0 v v v i ol = 100 a (4) i ol = 0.8 ma (4) i ol = 1.6ma (4) v ol1 output low voltage, port 0, ale, psen (6) 0.3 0.45 1.0 v v v i ol = 200 a (4) i ol = 1.6 ma (4) i ol = 3.5 ma (4) v oh output high voltage, ports 1, 2, 3, 4 and 5 v cc - 0.3 v cc - 0.7 v cc - 1.5 v v v i oh = -10 a i oh = -30 a i oh = -60 a v cc = 3.3v 10% v oh1 output high voltage, port 0, ale, psen v cc - 0.3 v cc - 0.7 v cc - 1.5 v v v i oh = -200 a i oh = -1.6 ma i oh = -3.5 ma v cc = 3.3v 10% r rst rst pullup resistor 50 100 200 k i il logical 0 input current ports 1, 2, 3 and 4 -50 a vin = 0.45v i li input leakage current 10 a0.45v < vin < v cc i tl logical 1 to 0 transition current, ports 1, 2, 3 and 4 -650 a vin = 2.0v c io capacitance of i/o buffer 10 pf fc = 1 mhz t a = 25 c i pd power-down current 100 a3.0v < v cc < 3.6v (3) i cc power supply current i ccop = 0.4xf(mhz)+5 i ccidle = 0.3xf(mhz)+5 i ccwrite = 0.8xf(mhz)+15 v cc = 3.3v (1)(2) v pfdp power fail high level threshold 3.0 v
160 at89c5131a-l 4338e?usb?06/06 notes: 1. operating i cc is measured with all output pins disconnected; xtal1 driven with t clch , t chcl = 5 ns (see figure 80.), v il = v ss + 0.5v, v ih = v cc - 0.5v; xtal2 n.c.; ea = rst = port 0 = v cc . i cc would be slightly higher if a crystal oscillator used (see figure 77.). 2. idle i cc is measured with all output pins disconnected; xtal1 driven with t clch , t chcl = 5 ns, v il = v ss + 0.5v, v ih = v cc - 0.5v; xtal2 n.c; port 0 = v cc ; ea = rst = v ss (see figure 78). 3. power-down i cc is measured with all output pins disconnected; ea = v cc , port 0 = v cc ; xtal2 nc.; rst = v ss (see fig- ure 79.). in addition, the wdt must be inactive and the pof flag must be set. 4. capacitance loading on ports 0 and 2 may cause spurious noise pulses to be superimposed on the v ols of ale and ports 1 and 3. the noise is due to external bus capacitance discharging into the port 0 and port 2 pins when these pins make 1 to 0 transitions during bus operation. in the worst cases (capacitive loading 100 pf), the noise pulse on the ale line may exceed 0.45v with maxi v ol peak 0.6v. a schmitt trigger use is not necessary. 5. typicals are based on a limited number of samples and are not guaranteed. the values listed are at room temperature. 6. under steady state (non-transient) conditions, i ol must be externally limited as follows: maximum i ol per port pin: 10 ma maximum i ol per 8-bit port: port 0: 26 ma ports 1, 2 and 3: 15 ma maximum total i ol for all output pins: 71 ma if i ol exceeds the test condition, v ol may exceed the related specification. pins are not guaranteed to sink current greater than the listed test conditions. figure 77. i cc test condition, active mode v pfdm power fail low level threshold 2.2 v power fail hysteresis v pfdp - v pfdm 0.15 v symbol parameter min typ (5) max unit test conditions ea v cc v cc i cc (nc) clock signal all other pins are disconnected. rst xtal2 xtal1 v ss v cc p0
161 at89c5131a-l 4338e?usb?06/06 figure 78. i cc test condition, idle mode figure 79. i cc test condition, power-down mode figure 80. clock signal waveform for i cc tests in active and idle modes led?s note: 1. (t a = -20 c to +50 c, v cc - v ol = 2 v 20%) rst ea xtal2 xtal1 v ss v cc v cc i cc (nc) p0 v cc all other pins are disconnected. clock signal v cc rst ea xtal2 xtal1 v ss v cc v cc i cc (nc) p0 v cc all other pins are disconnected . v cc v cc -0.5v 0.45v 0.7v cc 0.2v cc -0.1 t clch t chcl t clch = t chcl = 5ns. table 113. led outputs dc parameters symbol parameter min typ max unit test conditions i ol output low current, p3.6 and p3.7 led modes 1 2 5 2 4 10 4 8 20 ma ma ma 2 ma configuration 4 ma configuration 10 ma configuration
162 at89c5131a-l 4338e?usb?06/06 usb dc parameters symbol parameter min typ max unit v ref usb reference voltage 3.0 3.6 v v ih input high voltage for d+ and d- (driven) 2.0 v v ihz input high voltage for d+ and d- (floating) 2.7 3.6 v v il input low voltage for d+ and d- 0.8 v v oh output high voltage for d+ and d- 2.8 3.6 v v ol output low voltage for d+ and d- 0.0 0.3 v 1 4 2 3 1 - v bus 2 - d - 3 - d + 4 - gnd usb ?b? receptacle v ref d + d - r rpad rpad r = 1.5 k r pad = 27
163 at89c5131a-l 4338e?usb?06/06 ac parameters explanation of the ac symbols each timing symbol has 5 characters. the first character is always a ?t? (stands for time). the other characters, depending on their positions, stand for the name of a signal or the logical status of that signal. the following is a list of all the characters and what they stand for. example:t avll = time for address valid to ale low. t llpl = time for ale low to psen low. t a = -40 c to +85 c; v ss = 0v; v cc = 3.3v 10%; f = 0 to 40 mhz. t a = -40 c to +85 c; v ss = 0v; v cc = 3.3v 10%. (load capacitance for port 0, ale and psen = 60 pf; load capacitance for all other outputs = 60 pf.) table 114, table 117 and table 120 give the description of each ac symbols. table 115, table 119 and table 121 give for each range the ac parameter. table 116, table 119 and table 122 give the frequency derating formula of the ac parameter for each speed range description. to calculate each ac symbols. take the x value and use this value in the formula. example: t lliv and 20 mhz, standard clock. x = 30 ns t = 50 ns t cciv = 4t - x = 170 ns external program memory characteristics table 114. symbol description symbol parameter t oscillator clock period t lhll ale pulse width t avll address valid to ale t llax address hold after ale t lliv ale to valid instruction in t llpl ale to psen t plph psen pulse width t pliv psen to valid instruction in t pxix input instruction hold after psen t pxiz input instruction float after psen t aviv address to valid instruction in t plaz psen low to address float
164 at89c5131a-l 4338e?usb?06/06 table 115. ac parameters for a fix clock (f = 40 mhz) table 116. ac parameters for a variable clock symbol min max units t25 ns t lhll 40 ns t av l l 10 ns t llax 10 ns t lliv 70 ns t llpl 15 ns t plph 55 ns t pliv 35 ns t pxix 0ns t pxiz 18 ns t av iv 85 ns t plaz 10 ns symbol type standard clock x2 clock x parameter units t lhll min 2 t - x t - x 10 ns t avll min t - x 0.5 t - x 15 ns t llax min t - x 0.5 t - x 15 ns t lliv max 4 t - x 2 t - x 30 ns t llpl min t - x 0.5 t - x 10 ns t plph min 3 t - x 1.5 t - x 20 ns t pliv max 3 t - x 1.5 t - x 40 ns t pxix min x x 0 ns t pxiz max t - x 0.5 t - x 7 ns t aviv max 5 t - x 2.5 t - x 40 ns t plaz max x x 10 ns
165 at89c5131a-l 4338e?usb?06/06 external program memory read cycle external data memory characteristics table 117. symbol description t pliv tplaz ale psen port 0 port 2 a0-a7 a0-a7 instr in instr in instr in address or sfr-p2 address a8-a15 address a8-a15 12 t clcl t aviv t lhll t av l l t lliv t llpl t plph t pxav t pxix t pxiz t llax symbol parameter t rlrh rd pulse width t wlwh wr pulse width t rldv rd to valid data in t rhdx data hold after rd t rhdz data float after rd t lldv ale to valid data in t av d v address to valid data in t llwl ale to wr or rd t avwl address to wr or rd t qvwx data valid to wr transition t qvwh data set-up to wr high t whqx data hold after wr t rlaz rd low to address float t whlh rd or wr high to ale high
166 at89c5131a-l 4338e?usb?06/06 table 118. ac parameters for a variable clock (f = 40 mhz) symbol min max units t rlrh 130 ns t wlwh 130 ns t rldv 100 ns t rhdx 0ns t rhdz 30 ns t lldv 160 ns t avdv 165 ns t llwl 50 100 ns t avwl 75 ns t qvwx 10 ns t qvwh 160 ns t whqx 15 ns t rlaz 0ns t whlh 10 40 ns
167 at89c5131a-l 4338e?usb?06/06 table 119. ac parameters for a variable clock external data memory write cycle symbol type standard clock x2 clock x parameter units t rlrh min 6 t - x 3 t - x 20 ns t wlwh min 6 t - x 3 t - x 20 ns t rldv max 5 t - x 2.5 t - x 25 ns t rhdx min x x 0 ns t rhdz max 2 t - x t - x 20 ns t lldv max 8 t - x 4t -x 40 ns t avdv max 9 t - x 4.5 t - x 60 ns t llwl min 3 t - x 1.5 t - x 25 ns t llwl max 3 t + x 1.5 t + x 25 ns t avwl min 4 t - x 2 t - x 25 ns t qvwx min t - x 0.5 t - x 15 ns t qvwh min 7 t - x 3.5 t - x 25 ns t whqx min t - x 0.5 t - x 10 ns t rlaz max x x 0 ns t whlh min t - x 0.5 t - x 15 ns t whlh max t + x 0.5 t + x 15 ns t qvwh t llax ale psen wr port 0 port 2 a0-a7 data out address or sfr-p2 t avwl t llwl t qvwx address a8-a15 or sfr p2 t whqx t whlh t wlwh
168 at89c5131a-l 4338e?usb?06/06 external data memory read cycle serial port timing - shift register mode table 120. symbol description (f = 40 mhz) table 121. ac parameters for a fix clock (f = 40 mhz) table 122. ac parameters for a variable clock ale psen rd port 0 port 2 a0-a7 data in address or sfr-p2 t avwl t llwl t rlaz address a8-a15 or sfr p2 t rhdz t whlh t rlrh t lldv t rhdx t llax t avdv symbol parameter t xlxl serial port clock cycle time t qvhx output data set-up to clock rising edge t xhqx output data hold after clock rising edge t xhdx input data hold after clock rising edge t xhdv clock rising edge to input data valid symbol min max units t xlxl 300 ns t qvhx 200 ns t xhqx 30 ns t xhdx 0ns t xhdv 117 ns symbol type standard clock x2 clock x parameter for -m range units t xlxl min 12 t 6 t ns t qvhx min 10 t - x 5 t - x 50 ns t xhqx min 2 t - x t - x 20 ns t xhdx min x x 0 ns t xhdv max 10 t - x 5 t- x 133 ns
169 at89c5131a-l 4338e?usb?06/06 shift register timing waveform external clock drive characteristics (xtal1) table 123. ac parameters external clock drive waveforms ac testing input/output waveforms ac inputs during testing are driven at v cc - 0.5 for a logic ?1? and 0.45v for a logic ?0?. timing measurement are made at v ih min for a logic ?1? and v il max for a logic ?0?. float waveforms valid valid valid valid valid valid input data valid 0123456 8 7 ale clock output data write to sbuf clear ri t xlxl t qvxh t xhqx t xhdv t xhdx set ti set ri instruction 01234567 valid symbol parameter min max units t clcl oscillator period 21 ns t chcx high time 5 ns t clcx low time 5 ns t clch rise time 5 ns t chcl fall time 5 ns t chcx /t clcx cyclic ratio in x2 mode 40 60 % v cc -0.5v 0.45v 0.7v cc 0.2v cc -0.1 t chcl t clcx t clcl t clch t chcx input/output 0.2 v cc + 0.9 0.2 v cc - 0.1 v cc -0.5v 0.45v float v oh - 0.1 v v ol + 0.1 v v load v load + 0.1 v v load - 0.1 v
170 at89c5131a-l 4338e?usb?06/06 for timing purposes as port pin is no longer floating when a 100 mv change from load voltage occurs and begins to float when a 100 mv change from the loaded v oh /v ol level occurs. i ol /i oh 20 ma.
171 at89c5131a-l 4338e?usb?06/06 clock waveforms valid in normal clock mode. in x2 mode xtal2 must be changed to xtal2/2. this diagram indicates when signals are clocked internally. the time it takes the signals to propagate to the pins, however, ranges from 25 to 125 ns. this propagation delay is dependent on variables such as temperature and pin loading. propaga- tion also varies from output to output and component. typically though (t a = 25 c fully loaded) rd and wr propagation delays are approximately 50 ns. the other signals are typically 85 ns. propagation delays are incorporated in the ac specifications. data pcl out data pcl out data pcl out sampled sampled sampled state4 state5 state6 state1 state2 state3 state4 state5 p1 p2 p1 p2 p1 p2 p1 p2 p1 p2 p1 p2 p1 p2 p1 p2 float float float these signals are not activated during the execution of a movx instruction indicates address transitions external program memory fetch float data sampled dpl or rt out indicates dph or p2 sfr to pch transition pcl out (if program memory is external) pcl out (even if program memory is internal) pcl out (if progra m memory is externa l) old data new data p0 pins sampled p1, p2, p3 pins sampled p1, p2, p3 pins sampled p0 pins sampled rxd sampled internal clock xtal2 ale psen p0 p2 (ext) read cycle write cycle rd p0 p2 wr port operation mov port src mov dest p0 mov dest port (p1. p2. p3) (includes into. int1. to t1) serial port shift clock txd (mode 0) data out dpl or rt out indicates dph or p2 sfr to pch transition p0 p2 rxd sampled
172 at89c5131a-l 4338e?usb?06/06 flash eeprom memory and data eeprom memory table 124. timing symbol definitions table 125. memory ac timing vdd = 3.3v 10%, t a = -40 to +85 c figure 81. flash memory - isp waveforms figure 82. flash memory - internal busy waveforms signals conditions s (hardware condition) psen , ea l low rrst vvalid b fbusy flag x no longer valid symbol parameter min typ max unit t svrl input psen valid to rst edge 50 ns t rlsx input psen hold after rst edge 50 ns t bhbl flash eeprom internal busy (programming) time 10 20 ms t bhbl eeprom data internal busy (programming) time 10 20 ms flash eeprom program memory write cycles 100k cycles configuration bits (fuses bits) memory write cycles (bljb, x2, oscon0, oscon1) 1k cycles eeprom data memory write cycles 100k cycles rst t svrl psen 1 t rlsx fbusy bit t bhbl
173 at89c5131a-l 4338e?usb?06/06 usb ac parameters spi interface ac parameters definition of symbols table 127. spi interface timing symbol definitions rise time fall time v crs differential data lines 90% 10% 90% 10% t r t f v hmin v lmax table 126. usb ac parameters symbol parameter min typ max unit test conditions t r rise time 4 20 ns t f fall time 4 20 ns t fdrate full-speed data rate 11.9700 12.0300 mb/s v crs crossover voltage 1.3 2.0 v t dj1 source jitter total to next transaction -3.5 3.5 ns t dj2 source jitter total for paired transactions -4 4 ns t jr1 receiver jitter to next transaction -18.5 18.5 ns t jr2 receiver jitter for paired transactions -9 9 ns signals conditions cclock hhigh i data in l low odata out v valid x no longer valid zfloating
174 at89c5131a-l 4338e?usb?06/06 timings test conditions: capacitive load on all pins= 50 pf. table 128. spi interface master ac timing v dd = 2.7 to 5.5 v, t a = -40 to +85 c note: t per is xtal period when spi interface operates in x2 mode or twice xtal period when spi inter- face operates in x1 mode. symbol parameter min max unit slave mode t chch clock period 2 t per t chcx clock high time 0.8 t per t clcx clock low time 0.8 t per t slch , t slcl ss low to clock edge 100 ns t ivcl , t ivch input data valid to clock edge 50 ns t clix , t chix input data hold after clock edge 50 ns t clov, t chov output data valid after clock edge 50 ns t clox , t chox output data hold time after clock edge 0 ns t clsh , t chsh ss high after clock edge 0 ns t slov ss low to output data valid 4t per +20 ns t shox output data hold after ss high 2t per +100 ns t shsl ss high to ss low 2t per +120 t ilih input rise time 2 s t ihil input fall time 2 s t oloh output rise time 100 ns t ohol output fall time 100 ns master mode t chch clock period 4 t per t chcx clock high time 2t per -20 ns t clcx clock low time 2t per -20 ns t ivcl , t ivch input data valid to clock edge 50 ns t clix , t chix input data hold after clock edge 50 ns t clov, t chov output data valid after clock edge 20 ns t clox , t chox output data hold time after clock edge 0 ns
175 at89c5131a-l 4338e?usb?06/06 waveforms figure 83. spi slave waveforms (cpha= 0) note: 1. not defined but generally the msb of the character which has just been received. figure 84. spi slave waveforms (cpha= 1) note: 1. not defined but generally the lsb of the character which has just been received. t slcl t slch t chcl t clch mosi (input) sck (cpol= 0) (input) ss (input) sck (cpol= 1) (input) miso (output) t chch t clcx t chcx t ivcl t clix t chix t ivch t chov t clov t chox t clox msb in bit 6 lsb in slave msb out slave lsb out bit 6 t slov (1) t shox t shsl t chsh t clsh t chcl t clch mosi (input) sck (cpol= 0) (input) ss (input) sck (cpol= 1) (input) miso (output) t chch t clcx t chcx t ivcl t clix t chix t ivch t clov t chov t clox t chox msb in bit 6 lsb in slave msb out slave lsb out bit 6 t slov (1) t shox t shsl t chsh t clsh t slcl t slch
176 at89c5131a-l 4338e?usb?06/06 figure 85. spi master waveforms (sscpha= 0) note: 1. ss handled by software using general purpose port pin. figure 86. spi master waveforms (sscpha= 1) ss handled by software using general purpose port pin. mosi (input) sck (cpol= 0) (output) ss (output) sck (cpol= 1) (output) miso (output) t chch t clcx t chcx t ivcl t clix t chix t ivch t chov t clov t chox t clox msb in bit 6 lsb in msb out port data lsb out port data bit 6 t chcl t clch mosi (input) sck (cpol= 0) (output) ss (1) (output) sck (cpol= 1) (output) miso (output) t chch t clcx t chcx t ivcl t clix t chix t ivch t chov t clov t chox t clox msb in bit 6 lsb in msb out port data lsb out port data bit 6 t chcl t clch
177 at89c5131a-l 4338e?usb?06/06 ordering information note: 1. optional packing and package options (please consult atmel sales representative): -tape and reel -dry pack -known good dice table 129. possible order entries part number memory size (kbytes) supply voltage temperature range package packing at89c5131a-rdtil 32 3.0 to 3.6v industrial vqfp64 tray at89c5131a-s3sil 32 3.0 to 3.6v industrial plcc52 stick AT89C5131A-TISIL 32 3.0 to 3.6v industrial so28 stick at89c5131a-rdtul 32 3.0 to 3.6v industrial & green vqfp64 tray at89c5131a-s3sul 32 3.0 to 3.6v industrial & green plcc52 stick at89c5131a-tisul 32 3.0 to 3.6v industrial & green so28 stick
178 at89c5131a-l 4338e?usb?06/06 packaging information 64-lead vqfp
179 at89c5131a-l 4338e?usb?06/06 52-lead plcc
180 at89c5131a-l 4338e?usb?06/06 28-lead so document revision history changes from 4338d - 09/05 to 4338e - 06/06 1. correction to figure 4 on page 11.
181 4338e?usb?06/06 table of content features................................................................................................. 1 description............................................................................................ 2 block diagram ...................................................................................... 3 pinout description................................................................................ 4 pinout.................................................................................................................... 4 signals .................................................................................................................. 6 typical application............................................................................. 11 recommended external components................................................................. 11 pcb recommandations ..................................................................................... 12 clock controller.................................................................................. 13 introduction ......................................................................................................... 13 oscillator............................................................................................................. 13 pll ..................................................................................................................... 14 registers............................................................................................................. 16 sfr mapping....................................................................................... 18 dual data pointer register ................................................................ 25 program/code memory ...................................................................... 27 external code memory access .......................................................................... 27 flash memory architecture................................................................................. 28 overview of fm0 operations .............................................................................. 29 registers............................................................................................................. 35 flash eeprom memory..................................................................... 36 general description............................................................................................ 36 features.............................................................................................................. 36 flash programming and erasure........................................................................ 36 flash registers and memory map...................................................................... 37 flash memory status.......................................................................................... 40 memory organization ......................................................................................... 40 eeprom data memory ...................................................................... 41 description.......................................................................................................... 41 write data in the column latches...................................................................... 41 programming ...................................................................................................... 41 read data........................................................................................................... 41 registers............................................................................................................. 42 in-system programming (isp)........................................................... 43
182 4338e?usb?06/06 table of content flash programming and erasure........................................................................ 43 boot process ...................................................................................................... 44 application-programming-interface .................................................................... 45 xrow bytes....................................................................................................... 45 hardware conditions .......................................................................................... 45 on-chip expanded ram (eram)....................................................... 47 timer 2................................................................................................. 50 auto-reload mode ............................................................................................... 50 programmable clock output .............................................................................. 51 programmable counter array (pca) ................................................ 55 pca capture mode............................................................................................. 62 16-bit software timer/compare mode................................................................ 62 high speed output mode ................................................................................... 63 pulse width modulator mode.............................................................................. 64 pca watchdog timer ......................................................................................... 65 serial i/o port...................................................................................... 66 framing error detection ..................................................................................... 66 automatic address recognition.......................................................................... 67 baud rate selection for uart for mode 1 and 3............................................... 69 uart registers.................................................................................................. 72 interrupt system ................................................................................. 76 overview............................................................................................................. 76 registers............................................................................................................. 77 interrupt sources and vector addresses............................................................ 84 keyboard interface ............................................................................. 85 introduction ......................................................................................................... 85 description.......................................................................................................... 85 registers............................................................................................................. 86 programmable led ............................................................................ 89 serial peripheral interface (spi) ........................................................ 90 features.............................................................................................................. 90 signal description............................................................................................... 90 functional description ........................................................................................ 92 two wire interface (twi).................................................................... 99 description........................................................................................................ 101 notes ................................................................................................................ 104 registers........................................................................................................... 114
183 4338e?usb?06/06 table of content usb controller.................................................................................. 116 description........................................................................................................ 116 configuration .................................................................................................... 119 read/write data fifo ...................................................................................... 121 bulk/interrupt transactions............................................................................... 122 control transactions......................................................................................... 126 isochronous transactions................................................................................. 127 miscellaneous................................................................................................... 129 suspend/resume management ....................................................................... 130 detach simulation............................................................................................. 133 usb interrupt system ....................................................................................... 133 usb registers .................................................................................................. 136 reset.................................................................................................. 148 introduction ....................................................................................................... 148 reset input ....................................................................................................... 148 reset output..................................................................................................... 149 power monitor................................................................................... 150 description........................................................................................................ 150 power management.......................................................................... 152 idle mode.......................................................................................................... 152 power-down mode............................................................................................ 152 registers........................................................................................................... 154 hardware watchdog timer .............................................................. 155 using the wdt ................................................................................................. 155 wdt during power-down and idle ................................................................... 156 once mode (on chip emulation)................................................... 157 ........................................................................... reduced emi mode 158 electrical characteristics................................................................. 159 absolute maximum ratings ............................................................................. 159 dc parameters................................................................................................. 159 usb dc parameters......................................................................................... 162 ac parameters ................................................................................................. 163 usb ac parameters......................................................................................... 173 spi interface ac parameters ........................................................................... 173 ordering information........................................................................ 177 packaging information..................................................................... 178 64-lead vqfp................................................................................................... 178 52-lead plcc ................................................................................................... 179
184 4338e?usb?06/06 table of content 28-lead so........................................................................................................ 180 document revision history............................................................. 180 changes from 4338d - 09/05 to 4338e - 06/06................................................ 180
printed on recycled paper. 4338e?usb?06/06 ? atmel corporation 2006 . all rights reserved. atmel ? , logo and combinations thereof, are registered trademarks, and everywhere you are ? are the trademarks of atmel corporation or its subsidiaries. other terms and product names may be trademarks of others. disclaimer: the information in this document is provided in connection with atmel products. no license, express or implied, by estoppel or otherwise, to any intellectual property right is granted by this document or in connection with the sale of atmel products. except as set forth in atmel?s terms and condi- tions of sale located on atmel?s web site, atmel assumes no liability whatsoever and disclaims any express, implied or statutor y warranty relating to its products including, but not limited to, the implied warranty of merchantability, fitness for a particu lar purpose, or non-infringement. in no event shall atmel be liable for any direct, indirect, consequential, punitive, special or i nciden- tal damages (including, without limitation, damages for loss of profits, business interruption, or loss of information) arising out of the use or inability to use this document, even if atmel has been advised of the possibility of such damages. atmel makes no representations or warranties with respect to the accuracy or completeness of the contents of this document and reserves the rig ht to make changes to specifications and product descriptions at any time without notice. atmel does not make any commitment to update the information contained her ein. unless specifically provided otherwise, atmel products are not suitable for, and shall not be used in, automotive applications. atmel?s products are not int ended, authorized, or warranted for use as components in applications intended to support or sustain life. atmel corporation atmel operations 2325 orchard parkway san jose, ca 95131, usa tel: 1(408) 441-0311 fax: 1(408) 487-2600 regional headquarters europe atmel sarl route des arsenaux 41 case postale 80 ch-1705 fribourg switzerland tel: (41) 26-426-5555 fax: (41) 26-426-5500 asia room 1219 chinachem golden plaza 77 mody road tsimshatsui east kowloon hong kong tel: (852) 2721-9778 fax: (852) 2722-1369 japan 9f, tonetsu shinkawa bldg. 1-24-8 shinkawa chuo-ku, tokyo 104-0033 japan tel: (81) 3-3523-3551 fax: (81) 3-3523-7581 memory 2325 orchard parkway san jose, ca 95131, usa tel: 1(408) 441-0311 fax: 1(408) 436-4314 microcontrollers 2325 orchard parkway san jose, ca 95131, usa tel: 1(408) 441-0311 fax: 1(408) 436-4314 la chantrerie bp 70602 44306 nantes cedex 3, france tel: (33) 2-40-18-18-18 fax: (33) 2-40-18-19-60 asic/assp/smart cards zone industrielle 13106 rousset cedex, france tel: (33) 4-42-53-60-00 fax: (33) 4-42-53-60-01 1150 east cheyenne mtn. blvd. colorado springs, co 80906, usa tel: 1(719) 576-3300 fax: 1(719) 540-1759 scottish enterprise technology park maxwell building east kilbride g75 0qr, scotland tel: (44) 1355-803-000 fax: (44) 1355-242-743 rf/automotive theresienstrasse 2 postfach 3535 74025 heilbronn, germany tel: (49) 71-31-67-0 fax: (49) 71-31-67-2340 1150 east cheyenne mtn. blvd. colorado springs, co 80906, usa tel: 1(719) 576-3300 fax: 1(719) 540-1759 biometrics/imaging/hi-rel mpu/ high speed converters/rf datacom avenue de rochepleine bp 123 38521 saint-egreve cedex, france tel: (33) 4-76-58-30-00 fax: (33) 4-76-58-34-80 literature requests www.atmel.com/literature


▲Up To Search▲   

 
Price & Availability of AT89C5131A-TISIL

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X